Skip to main content
Commonmark migration
Source Link

#Pyth, 27 24 22 bytes

Pyth, 27 24 22 bytes

ssrD0m,lded.gr0k@+Gr1G

Try it online here.

ssrD0m,lded.gr0k@+Gr1GQ   Implicit: Q=eval(input()), G=lowercase alphabet
                          Trailing Q inferred
                   r1G    Uppercase alphabet
                 +G       Concatenate with lowercase alphabet
                @     Q   Keep those characters in Q which are also in the above
           .g             Group the remaining characters, as k, using:
             r0k             Convert k to lowercase
                              (Grouping preserves relative order)
     m                    Map the sorted groups, as d, using:
       ld                   Length of d
      ,                     Pair the above with...
         ed                 ... last element of d
   D                      Sort the above...
  r 0                     ... by their lowercase values
ss                        Flatten, then concatenate the result of the above into a string, implicit print

Edit: Golfed 3 bytes by ordering by character before group, previous version: sm+ldedo,lNr0eN.gr0kf}r0TGQ

Edit 2: Golfed off another 2 bytes by formatting output before any ordering, previous version: sm+ldedlD.gr0krD0f}r0TGQ

Edit 3: Golfed off another byte by changing the filter, thanks to @FryAmTheEggman. Also had to fix a bug when OP clarified that a single letter can appear more than 9 times, which added a byte back on :o( Previous version: srD0m+lded.gr0kf}r0TGQ

#Pyth, 27 24 22 bytes

ssrD0m,lded.gr0k@+Gr1G

Try it online here.

ssrD0m,lded.gr0k@+Gr1GQ   Implicit: Q=eval(input()), G=lowercase alphabet
                          Trailing Q inferred
                   r1G    Uppercase alphabet
                 +G       Concatenate with lowercase alphabet
                @     Q   Keep those characters in Q which are also in the above
           .g             Group the remaining characters, as k, using:
             r0k             Convert k to lowercase
                              (Grouping preserves relative order)
     m                    Map the sorted groups, as d, using:
       ld                   Length of d
      ,                     Pair the above with...
         ed                 ... last element of d
   D                      Sort the above...
  r 0                     ... by their lowercase values
ss                        Flatten, then concatenate the result of the above into a string, implicit print

Edit: Golfed 3 bytes by ordering by character before group, previous version: sm+ldedo,lNr0eN.gr0kf}r0TGQ

Edit 2: Golfed off another 2 bytes by formatting output before any ordering, previous version: sm+ldedlD.gr0krD0f}r0TGQ

Edit 3: Golfed off another byte by changing the filter, thanks to @FryAmTheEggman. Also had to fix a bug when OP clarified that a single letter can appear more than 9 times, which added a byte back on :o( Previous version: srD0m+lded.gr0kf}r0TGQ

Pyth, 27 24 22 bytes

ssrD0m,lded.gr0k@+Gr1G

Try it online here.

ssrD0m,lded.gr0k@+Gr1GQ   Implicit: Q=eval(input()), G=lowercase alphabet
                          Trailing Q inferred
                   r1G    Uppercase alphabet
                 +G       Concatenate with lowercase alphabet
                @     Q   Keep those characters in Q which are also in the above
           .g             Group the remaining characters, as k, using:
             r0k             Convert k to lowercase
                              (Grouping preserves relative order)
     m                    Map the sorted groups, as d, using:
       ld                   Length of d
      ,                     Pair the above with...
         ed                 ... last element of d
   D                      Sort the above...
  r 0                     ... by their lowercase values
ss                        Flatten, then concatenate the result of the above into a string, implicit print

Edit: Golfed 3 bytes by ordering by character before group, previous version: sm+ldedo,lNr0eN.gr0kf}r0TGQ

Edit 2: Golfed off another 2 bytes by formatting output before any ordering, previous version: sm+ldedlD.gr0krD0f}r0TGQ

Edit 3: Golfed off another byte by changing the filter, thanks to @FryAmTheEggman. Also had to fix a bug when OP clarified that a single letter can appear more than 9 times, which added a byte back on :o( Previous version: srD0m+lded.gr0kf}r0TGQ

Golfed a byte, fixed a bug
Source Link
Sok
  • 6.2k
  • 1
  • 17
  • 30

#Pyth, 27 24 22 bytes

srD0m+ldedssrD0m,lded.gr0kf}r0TGQgr0k@+Gr1G

Try it online herehere.

srD0m+ldedssrD0m,lded.gr0kf}r0TGQgr0k@+Gr1GQ   Implicit: Q=eval(input()), G=lowercase alphabet
               f     Q   Filter keep elements ofTrailing Q, asinferred
 T, when truthy:
                r1G r0T   Uppercase alphabet
   Convert T to            +G       Concatenate with lowercase alphabet
                }@   G  Q   Keep Isthose thecharacters abovein Q which are also in G?the above
           .g             Group the remaining characters, as k, using:
             r0k             Convert k to lowercase
                              (Grouping preserves relative order)
     m                    Map the sorted groups, as d, using:
       ld                   Length of d
      ,  ed                 Last element ofPair dthe above with...
     +    ed                 Concatenate... thelast previouselement twoof resultsd
   D                      Sort the above...
  r 0                     ... by their lowercase values
sss                        ConcatenateFlatten, then concatenate the result of the above into a string, implicit print

Edit: Golfed 3 bytes by ordering by character before group, previous version: sm+ldedo,lNr0eN.gr0kf}r0TGQ

Edit 2: Golfed off another 2 bytes by formatting output before any ordering, previous version: sm+ldedlD.gr0krD0f}r0TGQ

Edit 3: Golfed off another byte by changing the filter, thanks to @FryAmTheEggman. Also had to fix a bug when OP clarified that a single letter can appear more than 9 times, which added a byte back on :o( Previous version: srD0m+lded.gr0kf}r0TGQ

#Pyth, 27 24 22 bytes

srD0m+lded.gr0kf}r0TGQ

Try it online here.

srD0m+lded.gr0kf}r0TGQ   Implicit: Q=eval(input()), G=lowercase alphabet
               f     Q   Filter keep elements of Q, as T, when truthy:
                 r0T       Convert T to lowercase
                }   G      Is the above in G?
          .g             Group the remaining characters, as k, using:
            r0k             Convert k to lowercase
                             (Grouping preserves relative order)
    m                    Map the sorted groups, as d, using:
      ld                   Length of d
        ed                 Last element of d
     +                     Concatenate the previous two results
  D                      Sort the above...
 r 0                     ... by their lowercase values
s                        Concatenate the result of the above into a string, implicit print

Edit: Golfed 3 bytes by ordering by character before group, previous version: sm+ldedo,lNr0eN.gr0kf}r0TGQ

Edit 2: Golfed off another 2 bytes by formatting output before any ordering, previous version: sm+ldedlD.gr0krD0f}r0TGQ

#Pyth, 27 24 22 bytes

ssrD0m,lded.gr0k@+Gr1G

Try it online here.

ssrD0m,lded.gr0k@+Gr1GQ   Implicit: Q=eval(input()), G=lowercase alphabet
                          Trailing Q inferred
                   r1G    Uppercase alphabet
                 +G       Concatenate with lowercase alphabet
                @     Q   Keep those characters in Q which are also in the above
           .g             Group the remaining characters, as k, using:
             r0k             Convert k to lowercase
                              (Grouping preserves relative order)
     m                    Map the sorted groups, as d, using:
       ld                   Length of d
      ,                     Pair the above with...
         ed                 ... last element of d
   D                      Sort the above...
  r 0                     ... by their lowercase values
ss                        Flatten, then concatenate the result of the above into a string, implicit print

Edit: Golfed 3 bytes by ordering by character before group, previous version: sm+ldedo,lNr0eN.gr0kf}r0TGQ

Edit 2: Golfed off another 2 bytes by formatting output before any ordering, previous version: sm+ldedlD.gr0krD0f}r0TGQ

Edit 3: Golfed off another byte by changing the filter, thanks to @FryAmTheEggman. Also had to fix a bug when OP clarified that a single letter can appear more than 9 times, which added a byte back on :o( Previous version: srD0m+lded.gr0kf}r0TGQ

Golfed 2 bytes
Source Link
Sok
  • 6.2k
  • 1
  • 17
  • 30

#Pyth, 27 2424 22 bytes

sm+ldedlDsrD0m+lded.gr0krD0fgr0kf}r0TGQ

Try it online herehere.

sm+ldedlDsrD0m+lded.gr0krD0fgr0kf}r0TGQ   Implicit: Q=eval(input()), G=lowercase alphabet
                 f     Q   Filter keep elements of Q, as T, when truthy:
                   r0T       Convert T to lowercase
                  }   G      Is the above in G?
               D           Sort the remaining characters...
              r 0          ... by their lowercase values
         .g                Group the remaining characters, as k, using:
           r0k  r0k             Convert k to lowercase
                             (Grouping preserves relative order)
     m   D                  SortMap the groups...
 sorted groups, as d, using:
  l    ld               ... by their lengths
 mLength of d
        ed               Map the sortedLast groups,element asof d, using:
   ld     +                   Length of d
Concatenate the previous two results
 ed D                     Last elementSort ofthe dabove...
  +    r 0                     Concatenate... theby previoustheir twolowercase resultsvalues
s                          Concatenate the result of the above into a string, implicit print

Edit: Golfed 3 bytes by ordering by character before group, previous version: sm+ldedo,lNr0eN.gr0kf}r0TGQ

Edit 2: Golfed off another 2 bytes by formatting output before any ordering, previous version: sm+ldedlD.gr0krD0f}r0TGQ

#Pyth, 27 24 bytes

sm+ldedlD.gr0krD0f}r0TGQ

Try it online here.

sm+ldedlD.gr0krD0f}r0TGQ   Implicit: Q=eval(input()), G=lowercase alphabet
                 f     Q   Filter keep elements of Q, as T, when truthy:
                   r0T       Convert T to lowercase
                  }   G      Is the above in G?
               D           Sort the remaining characters...
              r 0          ... by their lowercase values
         .g                Group the characters, as k, using:
           r0k               Convert k to lowercase
                             (Grouping preserves relative order)
        D                  Sort the groups...
       l                   ... by their lengths
 m                         Map the sorted groups, as d, using:
   ld                        Length of d
     ed                      Last element of d
  +                          Concatenate the previous two results
s                          Concatenate the result of the above into a string, implicit print

Edit: Golfed 3 bytes by ordering by character before group, previous version: sm+ldedo,lNr0eN.gr0kf}r0TGQ

#Pyth, 27 24 22 bytes

srD0m+lded.gr0kf}r0TGQ

Try it online here.

srD0m+lded.gr0kf}r0TGQ   Implicit: Q=eval(input()), G=lowercase alphabet
               f     Q   Filter keep elements of Q, as T, when truthy:
                 r0T       Convert T to lowercase
                }   G      Is the above in G?
          .g             Group the remaining characters, as k, using:
            r0k             Convert k to lowercase
                             (Grouping preserves relative order)
    m                    Map the sorted groups, as d, using:
      ld                   Length of d
        ed                 Last element of d
     +                     Concatenate the previous two results
  D                      Sort the above...
 r 0                     ... by their lowercase values
s                        Concatenate the result of the above into a string, implicit print

Edit: Golfed 3 bytes by ordering by character before group, previous version: sm+ldedo,lNr0eN.gr0kf}r0TGQ

Edit 2: Golfed off another 2 bytes by formatting output before any ordering, previous version: sm+ldedlD.gr0krD0f}r0TGQ

Golfed 3 bytes
Source Link
Sok
  • 6.2k
  • 1
  • 17
  • 30
Loading
Source Link
Sok
  • 6.2k
  • 1
  • 17
  • 30
Loading