Generate a password












13












$begingroup$


It is very hard to remember my password, so I came up with a way to generate a password.



The way I generate my password is from a word or a sentence, following these steps:




  1. Start from left to right


  2. Find the count of each letter



  3. Put letter with its count in an order




    • Letters with higher repetition will be in the end


    • Letters with the same repetition will be ordered alphabetically




  4. Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)


  5. Group letters ignoring case. In the output, use the case of the last occurrence in the input



Example:



Input: Kitkat Tango
(2k / 1i / 3T / 2a / 1n / 1g / 1o)
Output: 1g1i1n1o2a2k3T


Another example:



Input: Database Partitions Task
(1D / 5a / 4T / 1b / 3s / 1e / 1P / 1r / 2i / 1o / 1n / 3s / 1k)
Output: 1b1D1e1k1n1o1P1r2i3s4T5a


Note: the letters with 1 repeat are in the beginning ordered alphabetically
then the letters with more reps



This is code-golf, the shortest code wins.










share|improve this question











$endgroup$












  • $begingroup$
    By 'count in each letter', do you mean how many times a letter appears in the input sentence?
    $endgroup$
    – Embodiment of Ignorance
    13 hours ago






  • 10




    $begingroup$
    Can a letter appear more than 9 times?
    $endgroup$
    – Shaggy
    9 hours ago










  • $begingroup$
    Can we output as an array? e.g., ["1g","1i","1n","1o","2a","2k","3T"] or even [["1","g"],["1","i"],["1","n"],["1","o"],["2","a"],["2","k"],["3","T"]]
    $endgroup$
    – Shaggy
    7 hours ago










  • $begingroup$
    "Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)" - does this mean [a-z][A-Z] only?
    $endgroup$
    – Jonathan Allan
    4 hours ago








  • 2




    $begingroup$
    @manatwork: But that's not unclear (note, their answer didn't assume that letters appear less than 10 times), it's just trying to loosen the input restrictions.
    $endgroup$
    – BMO
    1 hour ago
















13












$begingroup$


It is very hard to remember my password, so I came up with a way to generate a password.



The way I generate my password is from a word or a sentence, following these steps:




  1. Start from left to right


  2. Find the count of each letter



  3. Put letter with its count in an order




    • Letters with higher repetition will be in the end


    • Letters with the same repetition will be ordered alphabetically




  4. Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)


  5. Group letters ignoring case. In the output, use the case of the last occurrence in the input



Example:



Input: Kitkat Tango
(2k / 1i / 3T / 2a / 1n / 1g / 1o)
Output: 1g1i1n1o2a2k3T


Another example:



Input: Database Partitions Task
(1D / 5a / 4T / 1b / 3s / 1e / 1P / 1r / 2i / 1o / 1n / 3s / 1k)
Output: 1b1D1e1k1n1o1P1r2i3s4T5a


Note: the letters with 1 repeat are in the beginning ordered alphabetically
then the letters with more reps



This is code-golf, the shortest code wins.










share|improve this question











$endgroup$












  • $begingroup$
    By 'count in each letter', do you mean how many times a letter appears in the input sentence?
    $endgroup$
    – Embodiment of Ignorance
    13 hours ago






  • 10




    $begingroup$
    Can a letter appear more than 9 times?
    $endgroup$
    – Shaggy
    9 hours ago










  • $begingroup$
    Can we output as an array? e.g., ["1g","1i","1n","1o","2a","2k","3T"] or even [["1","g"],["1","i"],["1","n"],["1","o"],["2","a"],["2","k"],["3","T"]]
    $endgroup$
    – Shaggy
    7 hours ago










  • $begingroup$
    "Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)" - does this mean [a-z][A-Z] only?
    $endgroup$
    – Jonathan Allan
    4 hours ago








  • 2




    $begingroup$
    @manatwork: But that's not unclear (note, their answer didn't assume that letters appear less than 10 times), it's just trying to loosen the input restrictions.
    $endgroup$
    – BMO
    1 hour ago














13












13








13





$begingroup$


It is very hard to remember my password, so I came up with a way to generate a password.



The way I generate my password is from a word or a sentence, following these steps:




  1. Start from left to right


  2. Find the count of each letter



  3. Put letter with its count in an order




    • Letters with higher repetition will be in the end


    • Letters with the same repetition will be ordered alphabetically




  4. Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)


  5. Group letters ignoring case. In the output, use the case of the last occurrence in the input



Example:



Input: Kitkat Tango
(2k / 1i / 3T / 2a / 1n / 1g / 1o)
Output: 1g1i1n1o2a2k3T


Another example:



Input: Database Partitions Task
(1D / 5a / 4T / 1b / 3s / 1e / 1P / 1r / 2i / 1o / 1n / 3s / 1k)
Output: 1b1D1e1k1n1o1P1r2i3s4T5a


Note: the letters with 1 repeat are in the beginning ordered alphabetically
then the letters with more reps



This is code-golf, the shortest code wins.










share|improve this question











$endgroup$




It is very hard to remember my password, so I came up with a way to generate a password.



The way I generate my password is from a word or a sentence, following these steps:




  1. Start from left to right


  2. Find the count of each letter



  3. Put letter with its count in an order




    • Letters with higher repetition will be in the end


    • Letters with the same repetition will be ordered alphabetically




  4. Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)


  5. Group letters ignoring case. In the output, use the case of the last occurrence in the input



Example:



Input: Kitkat Tango
(2k / 1i / 3T / 2a / 1n / 1g / 1o)
Output: 1g1i1n1o2a2k3T


Another example:



Input: Database Partitions Task
(1D / 5a / 4T / 1b / 3s / 1e / 1P / 1r / 2i / 1o / 1n / 3s / 1k)
Output: 1b1D1e1k1n1o1P1r2i3s4T5a


Note: the letters with 1 repeat are in the beginning ordered alphabetically
then the letters with more reps



This is code-golf, the shortest code wins.







code-golf word-puzzle






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 24 mins ago









Shaggy

19.3k21666




19.3k21666










asked 13 hours ago









asmgxasmgx

249110




249110












  • $begingroup$
    By 'count in each letter', do you mean how many times a letter appears in the input sentence?
    $endgroup$
    – Embodiment of Ignorance
    13 hours ago






  • 10




    $begingroup$
    Can a letter appear more than 9 times?
    $endgroup$
    – Shaggy
    9 hours ago










  • $begingroup$
    Can we output as an array? e.g., ["1g","1i","1n","1o","2a","2k","3T"] or even [["1","g"],["1","i"],["1","n"],["1","o"],["2","a"],["2","k"],["3","T"]]
    $endgroup$
    – Shaggy
    7 hours ago










  • $begingroup$
    "Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)" - does this mean [a-z][A-Z] only?
    $endgroup$
    – Jonathan Allan
    4 hours ago








  • 2




    $begingroup$
    @manatwork: But that's not unclear (note, their answer didn't assume that letters appear less than 10 times), it's just trying to loosen the input restrictions.
    $endgroup$
    – BMO
    1 hour ago


















  • $begingroup$
    By 'count in each letter', do you mean how many times a letter appears in the input sentence?
    $endgroup$
    – Embodiment of Ignorance
    13 hours ago






  • 10




    $begingroup$
    Can a letter appear more than 9 times?
    $endgroup$
    – Shaggy
    9 hours ago










  • $begingroup$
    Can we output as an array? e.g., ["1g","1i","1n","1o","2a","2k","3T"] or even [["1","g"],["1","i"],["1","n"],["1","o"],["2","a"],["2","k"],["3","T"]]
    $endgroup$
    – Shaggy
    7 hours ago










  • $begingroup$
    "Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)" - does this mean [a-z][A-Z] only?
    $endgroup$
    – Jonathan Allan
    4 hours ago








  • 2




    $begingroup$
    @manatwork: But that's not unclear (note, their answer didn't assume that letters appear less than 10 times), it's just trying to loosen the input restrictions.
    $endgroup$
    – BMO
    1 hour ago
















$begingroup$
By 'count in each letter', do you mean how many times a letter appears in the input sentence?
$endgroup$
– Embodiment of Ignorance
13 hours ago




$begingroup$
By 'count in each letter', do you mean how many times a letter appears in the input sentence?
$endgroup$
– Embodiment of Ignorance
13 hours ago




10




10




$begingroup$
Can a letter appear more than 9 times?
$endgroup$
– Shaggy
9 hours ago




$begingroup$
Can a letter appear more than 9 times?
$endgroup$
– Shaggy
9 hours ago












$begingroup$
Can we output as an array? e.g., ["1g","1i","1n","1o","2a","2k","3T"] or even [["1","g"],["1","i"],["1","n"],["1","o"],["2","a"],["2","k"],["3","T"]]
$endgroup$
– Shaggy
7 hours ago




$begingroup$
Can we output as an array? e.g., ["1g","1i","1n","1o","2a","2k","3T"] or even [["1","g"],["1","i"],["1","n"],["1","o"],["2","a"],["2","k"],["3","T"]]
$endgroup$
– Shaggy
7 hours ago












$begingroup$
"Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)" - does this mean [a-z][A-Z] only?
$endgroup$
– Jonathan Allan
4 hours ago






$begingroup$
"Numbers and special letters will be ignored including whitespace (e.g. 9, 4, @, (, *, etc. are ignored)" - does this mean [a-z][A-Z] only?
$endgroup$
– Jonathan Allan
4 hours ago






2




2




$begingroup$
@manatwork: But that's not unclear (note, their answer didn't assume that letters appear less than 10 times), it's just trying to loosen the input restrictions.
$endgroup$
– BMO
1 hour ago




$begingroup$
@manatwork: But that's not unclear (note, their answer didn't assume that letters appear less than 10 times), it's just trying to loosen the input restrictions.
$endgroup$
– BMO
1 hour ago










10 Answers
10






active

oldest

votes


















5












$begingroup$


05AB1E, 19 17 16 bytes



Saved 1 byte thanks to Kevin Cruijssen



áΣl}.γl}éεgyθJ}J


Try it online!
or as a Test Suite



Explanation



á                  # keep only letters in input
Σl} # sort by lower-case
.γl} # group by lower-case
é # sort by length (stable)
ε } # map each to
g # its length
J # joined with
yθ # the last letter
J # join to string





share|improve this answer











$endgroup$













  • $begingroup$
    You can save a byte by changing the (pair with) to a « (concat/merge), so one of the two Js (joins) can be removed.
    $endgroup$
    – Kevin Cruijssen
    5 hours ago












  • $begingroup$
    @KevinCruijssen: Wow. I feel stupid now :) Why didn't I just move a J inside? Edit: Actually, I needed them as a pair in the 19-byte version and I didn't think to change it when I made the 17 one :P
    $endgroup$
    – Emigna
    4 hours ago












  • $begingroup$
    You might be able to drop the second Join, depending on the answer to this question
    $endgroup$
    – Shaggy
    26 mins ago



















4












$begingroup$


Japt v2.0a0 -P, 14 bytes



fl üv ñÊ®ÌiZÊ


Try it



fl üv ñÊ®ÌiZÊ     :Implicit input of string
> e.g., "Kitkat Tango"

f :Split to an array of characters
l : Matching RegEx /[a-z]/gi
> ["K","i","t","k","a","t","T","a","n","g","o"]

ü :Sort & group (Preserves original order within each group)
v : By lowercase
> [["a","a"],["g"],["i"],["K","k"],["n"],["o"],["t","t","T"]]

ñ :Sort
Ê : By length
> [["g"],["i"],["n"],["o"],["a","a"],["K","k"],["t","t","T"]]

® :Map each Z
Ì : Last element of Z
> ["g","i","n","o","a","k","T"]
i : Prepend
ZÊ : Length of Z
> ["1g","1i","1n","1o","2a","2k","3T"]

:Implicitly join & output
> "1g1i1n1o2a2k3T"





share|improve this answer











$endgroup$





















    3












    $begingroup$


    Retina, 67 66 41 bytes



    [Wd_]

    O$`.
    $l$0
    ir`1*(.)
    $.0$1
    N`d+.


    -25 bytes and a minor bug-fix thanks to @Neil.



    Try it online or verify all test cases.



    Explanation:



    Remove everything except for upper- and lowercase letters:

    i.e. Kitkat Tango 123!KitkatTango



    [Wd_]



    Sort the individual letters case-insensitive (thanks to @MartinEnder for this):

    i.e. KitkatTangoaagiKknottT



    O$`.
    $l$0


    Capture every chunk of case-insensitive repeated adjacent letters:

    i.e. aagiKknottT → [aa,g,i,Kk,n,o,ttT]



    ir`1*(.)


    Prepend the length of every match, and only keep the last letter of every chunk:

    i.e. [aa,g,i,Kk,n,o,ttT] → 2a1g1i2k1n1o3T



    $.0$1


    Sort the numbers and letter groups based on the numbers:
    2a1g1i2k1n1o3T1g1i1n1o2a2k3T



    N`d+.


    After which the result is output implicitly.






    share|improve this answer











    $endgroup$













    • $begingroup$
      Are you sure that's a bug? Is it not just sorting lexicographically? ("aA" < "aa")
      $endgroup$
      – Shaggy
      7 hours ago










    • $begingroup$
      @Shaggy You're right it's not a bug. I meant a bug in my program, not in Retina itself. It's behaving as you would expect indeed. I've edited it to 'problem'. If only I could do O$i to sort case-insensitive, just like I can List or match case-insensitive by using $i..
      $endgroup$
      – Kevin Cruijssen
      7 hours ago






    • 1




      $begingroup$
      @Shaggy I'm not sure if it can. Because the w and . in the O`w. were used to indicate that we're sorting pairs of characters. Not sure if we can sort every pair of characters, but only sort it based on the first character. But ah well, Martin's suggestion to sort each character based on a substitution (which is the lowercase variant of the match) works like a charm. :)
      $endgroup$
      – Kevin Cruijssen
      7 hours ago






    • 1




      $begingroup$
      Can it be done in 41 bytes or am I missing something?
      $endgroup$
      – Neil
      5 hours ago






    • 1




      $begingroup$
      github.com/m-ender/retina/wiki/The-Language#regex-modifiers
      $endgroup$
      – Neil
      4 hours ago



















    2












    $begingroup$


    Perl 6, 66 bytes





    {[~] map {+$_~.tail},sort {+$_,.lc},values classify &lc,m:g/<:L>/}


    Try it online!






    share|improve this answer









    $endgroup$





















      2












      $begingroup$

      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






      share|improve this answer











      $endgroup$













      • $begingroup$
        @+GrG1 seems to save a byte for filtering. It's also worth noting that your sorting method won't always work if a character appears 10 or more times, but that hasn't been clarified yet.
        $endgroup$
        – FryAmTheEggman
        18 mins ago



















      1












      $begingroup$


      Python 2, 99 bytes





      def f(s):a=s.lower();return''.join(sorted(`a.count(c)`+s[a.rfind(c)]for c in set(a)if c.isalpha()))


      Try it online!






      share|improve this answer









      $endgroup$













      • $begingroup$
        The output for Database Partitions Task is not equal to 1b1D1e1k1n1o1P1r2i3s4T5a
        $endgroup$
        – mdahmoune
        1 hour ago



















      1












      $begingroup$


      Red, 220 196 bytes



      func[s][a: charset[#"a"-#"z"#"A"-#"Z"]rejoin sort collect[foreach c sort
      unique reverse rejoin parse s[collect[any[keep[a]| skip]]][i: 0
      foreach d s[if(c% 32)=(d% 32)[i: i + 1]]keep rejoin[i c]]]]


      Try it online!






      share|improve this answer











      $endgroup$





















        1












        $begingroup$

        Perl 5, 74 68 bytes



        -6 bytes changing -p to -n and using say instead of $_=join"",



        s/[a-z]/($h{lc$&}+=1).=$&/gie;say sort{$a-$b||lc$a cmp lc$b}values%h


        TIO



        61 bytes, in case there is no more than 9 occurence of each character



        s/[a-z]/($h{lc$&}+=1).=$&/gie;print sort{lc$a cmp lc$b}values%h





        share|improve this answer











        $endgroup$





















          1












          $begingroup$


          Jelly, 15 bytes



          fØẠµŒlĠLÞịµL,Ṫ)


          A full program printing the password as specified (as a monadic Link it yields a list of lists each containing an integer and a character).



          Try it online!






          share|improve this answer









          $endgroup$





















            0












            $begingroup$


            Charcoal, 30 bytes



            F⌈Eβ№↧θιFβ¿⁼№↧θκ⊕ι⁺⊕ι§Φθ⁼↧λκ±¹


            Try it online! Link is to verbose version of code. Explanation:



            F⌈Eβ№↧θι


            Run through the lowercase alphabet and find the highest character count in the lowercased input. Loop over the implicit range. (The loop actually goes from 0 to n-1 so I have to increment the loop variable at each use.)



            Fβ


            Loop over the lowercase alphabet again.



            ¿⁼№↧θκ⊕ι


            If the count of the current letter is equal to the outer loop value...



            ⁺⊕ι§Φθ⁼↧λκ±¹


            Concatenate the current count with the last occurrence of the current letter and implicitly print.






            share|improve this answer









            $endgroup$













              Your Answer





              StackExchange.ifUsing("editor", function () {
              return StackExchange.using("mathjaxEditing", function () {
              StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
              StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
              });
              });
              }, "mathjax-editing");

              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "200"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f178888%2fgenerate-a-password%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              10 Answers
              10






              active

              oldest

              votes








              10 Answers
              10






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              5












              $begingroup$


              05AB1E, 19 17 16 bytes



              Saved 1 byte thanks to Kevin Cruijssen



              áΣl}.γl}éεgyθJ}J


              Try it online!
              or as a Test Suite



              Explanation



              á                  # keep only letters in input
              Σl} # sort by lower-case
              .γl} # group by lower-case
              é # sort by length (stable)
              ε } # map each to
              g # its length
              J # joined with
              yθ # the last letter
              J # join to string





              share|improve this answer











              $endgroup$













              • $begingroup$
                You can save a byte by changing the (pair with) to a « (concat/merge), so one of the two Js (joins) can be removed.
                $endgroup$
                – Kevin Cruijssen
                5 hours ago












              • $begingroup$
                @KevinCruijssen: Wow. I feel stupid now :) Why didn't I just move a J inside? Edit: Actually, I needed them as a pair in the 19-byte version and I didn't think to change it when I made the 17 one :P
                $endgroup$
                – Emigna
                4 hours ago












              • $begingroup$
                You might be able to drop the second Join, depending on the answer to this question
                $endgroup$
                – Shaggy
                26 mins ago
















              5












              $begingroup$


              05AB1E, 19 17 16 bytes



              Saved 1 byte thanks to Kevin Cruijssen



              áΣl}.γl}éεgyθJ}J


              Try it online!
              or as a Test Suite



              Explanation



              á                  # keep only letters in input
              Σl} # sort by lower-case
              .γl} # group by lower-case
              é # sort by length (stable)
              ε } # map each to
              g # its length
              J # joined with
              yθ # the last letter
              J # join to string





              share|improve this answer











              $endgroup$













              • $begingroup$
                You can save a byte by changing the (pair with) to a « (concat/merge), so one of the two Js (joins) can be removed.
                $endgroup$
                – Kevin Cruijssen
                5 hours ago












              • $begingroup$
                @KevinCruijssen: Wow. I feel stupid now :) Why didn't I just move a J inside? Edit: Actually, I needed them as a pair in the 19-byte version and I didn't think to change it when I made the 17 one :P
                $endgroup$
                – Emigna
                4 hours ago












              • $begingroup$
                You might be able to drop the second Join, depending on the answer to this question
                $endgroup$
                – Shaggy
                26 mins ago














              5












              5








              5





              $begingroup$


              05AB1E, 19 17 16 bytes



              Saved 1 byte thanks to Kevin Cruijssen



              áΣl}.γl}éεgyθJ}J


              Try it online!
              or as a Test Suite



              Explanation



              á                  # keep only letters in input
              Σl} # sort by lower-case
              .γl} # group by lower-case
              é # sort by length (stable)
              ε } # map each to
              g # its length
              J # joined with
              yθ # the last letter
              J # join to string





              share|improve this answer











              $endgroup$




              05AB1E, 19 17 16 bytes



              Saved 1 byte thanks to Kevin Cruijssen



              áΣl}.γl}éεgyθJ}J


              Try it online!
              or as a Test Suite



              Explanation



              á                  # keep only letters in input
              Σl} # sort by lower-case
              .γl} # group by lower-case
              é # sort by length (stable)
              ε } # map each to
              g # its length
              J # joined with
              yθ # the last letter
              J # join to string






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited 4 hours ago

























              answered 10 hours ago









              EmignaEmigna

              45.7k432139




              45.7k432139












              • $begingroup$
                You can save a byte by changing the (pair with) to a « (concat/merge), so one of the two Js (joins) can be removed.
                $endgroup$
                – Kevin Cruijssen
                5 hours ago












              • $begingroup$
                @KevinCruijssen: Wow. I feel stupid now :) Why didn't I just move a J inside? Edit: Actually, I needed them as a pair in the 19-byte version and I didn't think to change it when I made the 17 one :P
                $endgroup$
                – Emigna
                4 hours ago












              • $begingroup$
                You might be able to drop the second Join, depending on the answer to this question
                $endgroup$
                – Shaggy
                26 mins ago


















              • $begingroup$
                You can save a byte by changing the (pair with) to a « (concat/merge), so one of the two Js (joins) can be removed.
                $endgroup$
                – Kevin Cruijssen
                5 hours ago












              • $begingroup$
                @KevinCruijssen: Wow. I feel stupid now :) Why didn't I just move a J inside? Edit: Actually, I needed them as a pair in the 19-byte version and I didn't think to change it when I made the 17 one :P
                $endgroup$
                – Emigna
                4 hours ago












              • $begingroup$
                You might be able to drop the second Join, depending on the answer to this question
                $endgroup$
                – Shaggy
                26 mins ago
















              $begingroup$
              You can save a byte by changing the (pair with) to a « (concat/merge), so one of the two Js (joins) can be removed.
              $endgroup$
              – Kevin Cruijssen
              5 hours ago






              $begingroup$
              You can save a byte by changing the (pair with) to a « (concat/merge), so one of the two Js (joins) can be removed.
              $endgroup$
              – Kevin Cruijssen
              5 hours ago














              $begingroup$
              @KevinCruijssen: Wow. I feel stupid now :) Why didn't I just move a J inside? Edit: Actually, I needed them as a pair in the 19-byte version and I didn't think to change it when I made the 17 one :P
              $endgroup$
              – Emigna
              4 hours ago






              $begingroup$
              @KevinCruijssen: Wow. I feel stupid now :) Why didn't I just move a J inside? Edit: Actually, I needed them as a pair in the 19-byte version and I didn't think to change it when I made the 17 one :P
              $endgroup$
              – Emigna
              4 hours ago














              $begingroup$
              You might be able to drop the second Join, depending on the answer to this question
              $endgroup$
              – Shaggy
              26 mins ago




              $begingroup$
              You might be able to drop the second Join, depending on the answer to this question
              $endgroup$
              – Shaggy
              26 mins ago











              4












              $begingroup$


              Japt v2.0a0 -P, 14 bytes



              fl üv ñÊ®ÌiZÊ


              Try it



              fl üv ñÊ®ÌiZÊ     :Implicit input of string
              > e.g., "Kitkat Tango"

              f :Split to an array of characters
              l : Matching RegEx /[a-z]/gi
              > ["K","i","t","k","a","t","T","a","n","g","o"]

              ü :Sort & group (Preserves original order within each group)
              v : By lowercase
              > [["a","a"],["g"],["i"],["K","k"],["n"],["o"],["t","t","T"]]

              ñ :Sort
              Ê : By length
              > [["g"],["i"],["n"],["o"],["a","a"],["K","k"],["t","t","T"]]

              ® :Map each Z
              Ì : Last element of Z
              > ["g","i","n","o","a","k","T"]
              i : Prepend
              ZÊ : Length of Z
              > ["1g","1i","1n","1o","2a","2k","3T"]

              :Implicitly join & output
              > "1g1i1n1o2a2k3T"





              share|improve this answer











              $endgroup$


















                4












                $begingroup$


                Japt v2.0a0 -P, 14 bytes



                fl üv ñÊ®ÌiZÊ


                Try it



                fl üv ñÊ®ÌiZÊ     :Implicit input of string
                > e.g., "Kitkat Tango"

                f :Split to an array of characters
                l : Matching RegEx /[a-z]/gi
                > ["K","i","t","k","a","t","T","a","n","g","o"]

                ü :Sort & group (Preserves original order within each group)
                v : By lowercase
                > [["a","a"],["g"],["i"],["K","k"],["n"],["o"],["t","t","T"]]

                ñ :Sort
                Ê : By length
                > [["g"],["i"],["n"],["o"],["a","a"],["K","k"],["t","t","T"]]

                ® :Map each Z
                Ì : Last element of Z
                > ["g","i","n","o","a","k","T"]
                i : Prepend
                ZÊ : Length of Z
                > ["1g","1i","1n","1o","2a","2k","3T"]

                :Implicitly join & output
                > "1g1i1n1o2a2k3T"





                share|improve this answer











                $endgroup$
















                  4












                  4








                  4





                  $begingroup$


                  Japt v2.0a0 -P, 14 bytes



                  fl üv ñÊ®ÌiZÊ


                  Try it



                  fl üv ñÊ®ÌiZÊ     :Implicit input of string
                  > e.g., "Kitkat Tango"

                  f :Split to an array of characters
                  l : Matching RegEx /[a-z]/gi
                  > ["K","i","t","k","a","t","T","a","n","g","o"]

                  ü :Sort & group (Preserves original order within each group)
                  v : By lowercase
                  > [["a","a"],["g"],["i"],["K","k"],["n"],["o"],["t","t","T"]]

                  ñ :Sort
                  Ê : By length
                  > [["g"],["i"],["n"],["o"],["a","a"],["K","k"],["t","t","T"]]

                  ® :Map each Z
                  Ì : Last element of Z
                  > ["g","i","n","o","a","k","T"]
                  i : Prepend
                  ZÊ : Length of Z
                  > ["1g","1i","1n","1o","2a","2k","3T"]

                  :Implicitly join & output
                  > "1g1i1n1o2a2k3T"





                  share|improve this answer











                  $endgroup$




                  Japt v2.0a0 -P, 14 bytes



                  fl üv ñÊ®ÌiZÊ


                  Try it



                  fl üv ñÊ®ÌiZÊ     :Implicit input of string
                  > e.g., "Kitkat Tango"

                  f :Split to an array of characters
                  l : Matching RegEx /[a-z]/gi
                  > ["K","i","t","k","a","t","T","a","n","g","o"]

                  ü :Sort & group (Preserves original order within each group)
                  v : By lowercase
                  > [["a","a"],["g"],["i"],["K","k"],["n"],["o"],["t","t","T"]]

                  ñ :Sort
                  Ê : By length
                  > [["g"],["i"],["n"],["o"],["a","a"],["K","k"],["t","t","T"]]

                  ® :Map each Z
                  Ì : Last element of Z
                  > ["g","i","n","o","a","k","T"]
                  i : Prepend
                  ZÊ : Length of Z
                  > ["1g","1i","1n","1o","2a","2k","3T"]

                  :Implicitly join & output
                  > "1g1i1n1o2a2k3T"






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 6 hours ago

























                  answered 9 hours ago









                  ShaggyShaggy

                  19.3k21666




                  19.3k21666























                      3












                      $begingroup$


                      Retina, 67 66 41 bytes



                      [Wd_]

                      O$`.
                      $l$0
                      ir`1*(.)
                      $.0$1
                      N`d+.


                      -25 bytes and a minor bug-fix thanks to @Neil.



                      Try it online or verify all test cases.



                      Explanation:



                      Remove everything except for upper- and lowercase letters:

                      i.e. Kitkat Tango 123!KitkatTango



                      [Wd_]



                      Sort the individual letters case-insensitive (thanks to @MartinEnder for this):

                      i.e. KitkatTangoaagiKknottT



                      O$`.
                      $l$0


                      Capture every chunk of case-insensitive repeated adjacent letters:

                      i.e. aagiKknottT → [aa,g,i,Kk,n,o,ttT]



                      ir`1*(.)


                      Prepend the length of every match, and only keep the last letter of every chunk:

                      i.e. [aa,g,i,Kk,n,o,ttT] → 2a1g1i2k1n1o3T



                      $.0$1


                      Sort the numbers and letter groups based on the numbers:
                      2a1g1i2k1n1o3T1g1i1n1o2a2k3T



                      N`d+.


                      After which the result is output implicitly.






                      share|improve this answer











                      $endgroup$













                      • $begingroup$
                        Are you sure that's a bug? Is it not just sorting lexicographically? ("aA" < "aa")
                        $endgroup$
                        – Shaggy
                        7 hours ago










                      • $begingroup$
                        @Shaggy You're right it's not a bug. I meant a bug in my program, not in Retina itself. It's behaving as you would expect indeed. I've edited it to 'problem'. If only I could do O$i to sort case-insensitive, just like I can List or match case-insensitive by using $i..
                        $endgroup$
                        – Kevin Cruijssen
                        7 hours ago






                      • 1




                        $begingroup$
                        @Shaggy I'm not sure if it can. Because the w and . in the O`w. were used to indicate that we're sorting pairs of characters. Not sure if we can sort every pair of characters, but only sort it based on the first character. But ah well, Martin's suggestion to sort each character based on a substitution (which is the lowercase variant of the match) works like a charm. :)
                        $endgroup$
                        – Kevin Cruijssen
                        7 hours ago






                      • 1




                        $begingroup$
                        Can it be done in 41 bytes or am I missing something?
                        $endgroup$
                        – Neil
                        5 hours ago






                      • 1




                        $begingroup$
                        github.com/m-ender/retina/wiki/The-Language#regex-modifiers
                        $endgroup$
                        – Neil
                        4 hours ago
















                      3












                      $begingroup$


                      Retina, 67 66 41 bytes



                      [Wd_]

                      O$`.
                      $l$0
                      ir`1*(.)
                      $.0$1
                      N`d+.


                      -25 bytes and a minor bug-fix thanks to @Neil.



                      Try it online or verify all test cases.



                      Explanation:



                      Remove everything except for upper- and lowercase letters:

                      i.e. Kitkat Tango 123!KitkatTango



                      [Wd_]



                      Sort the individual letters case-insensitive (thanks to @MartinEnder for this):

                      i.e. KitkatTangoaagiKknottT



                      O$`.
                      $l$0


                      Capture every chunk of case-insensitive repeated adjacent letters:

                      i.e. aagiKknottT → [aa,g,i,Kk,n,o,ttT]



                      ir`1*(.)


                      Prepend the length of every match, and only keep the last letter of every chunk:

                      i.e. [aa,g,i,Kk,n,o,ttT] → 2a1g1i2k1n1o3T



                      $.0$1


                      Sort the numbers and letter groups based on the numbers:
                      2a1g1i2k1n1o3T1g1i1n1o2a2k3T



                      N`d+.


                      After which the result is output implicitly.






                      share|improve this answer











                      $endgroup$













                      • $begingroup$
                        Are you sure that's a bug? Is it not just sorting lexicographically? ("aA" < "aa")
                        $endgroup$
                        – Shaggy
                        7 hours ago










                      • $begingroup$
                        @Shaggy You're right it's not a bug. I meant a bug in my program, not in Retina itself. It's behaving as you would expect indeed. I've edited it to 'problem'. If only I could do O$i to sort case-insensitive, just like I can List or match case-insensitive by using $i..
                        $endgroup$
                        – Kevin Cruijssen
                        7 hours ago






                      • 1




                        $begingroup$
                        @Shaggy I'm not sure if it can. Because the w and . in the O`w. were used to indicate that we're sorting pairs of characters. Not sure if we can sort every pair of characters, but only sort it based on the first character. But ah well, Martin's suggestion to sort each character based on a substitution (which is the lowercase variant of the match) works like a charm. :)
                        $endgroup$
                        – Kevin Cruijssen
                        7 hours ago






                      • 1




                        $begingroup$
                        Can it be done in 41 bytes or am I missing something?
                        $endgroup$
                        – Neil
                        5 hours ago






                      • 1




                        $begingroup$
                        github.com/m-ender/retina/wiki/The-Language#regex-modifiers
                        $endgroup$
                        – Neil
                        4 hours ago














                      3












                      3








                      3





                      $begingroup$


                      Retina, 67 66 41 bytes



                      [Wd_]

                      O$`.
                      $l$0
                      ir`1*(.)
                      $.0$1
                      N`d+.


                      -25 bytes and a minor bug-fix thanks to @Neil.



                      Try it online or verify all test cases.



                      Explanation:



                      Remove everything except for upper- and lowercase letters:

                      i.e. Kitkat Tango 123!KitkatTango



                      [Wd_]



                      Sort the individual letters case-insensitive (thanks to @MartinEnder for this):

                      i.e. KitkatTangoaagiKknottT



                      O$`.
                      $l$0


                      Capture every chunk of case-insensitive repeated adjacent letters:

                      i.e. aagiKknottT → [aa,g,i,Kk,n,o,ttT]



                      ir`1*(.)


                      Prepend the length of every match, and only keep the last letter of every chunk:

                      i.e. [aa,g,i,Kk,n,o,ttT] → 2a1g1i2k1n1o3T



                      $.0$1


                      Sort the numbers and letter groups based on the numbers:
                      2a1g1i2k1n1o3T1g1i1n1o2a2k3T



                      N`d+.


                      After which the result is output implicitly.






                      share|improve this answer











                      $endgroup$




                      Retina, 67 66 41 bytes



                      [Wd_]

                      O$`.
                      $l$0
                      ir`1*(.)
                      $.0$1
                      N`d+.


                      -25 bytes and a minor bug-fix thanks to @Neil.



                      Try it online or verify all test cases.



                      Explanation:



                      Remove everything except for upper- and lowercase letters:

                      i.e. Kitkat Tango 123!KitkatTango



                      [Wd_]



                      Sort the individual letters case-insensitive (thanks to @MartinEnder for this):

                      i.e. KitkatTangoaagiKknottT



                      O$`.
                      $l$0


                      Capture every chunk of case-insensitive repeated adjacent letters:

                      i.e. aagiKknottT → [aa,g,i,Kk,n,o,ttT]



                      ir`1*(.)


                      Prepend the length of every match, and only keep the last letter of every chunk:

                      i.e. [aa,g,i,Kk,n,o,ttT] → 2a1g1i2k1n1o3T



                      $.0$1


                      Sort the numbers and letter groups based on the numbers:
                      2a1g1i2k1n1o3T1g1i1n1o2a2k3T



                      N`d+.


                      After which the result is output implicitly.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 4 hours ago

























                      answered 8 hours ago









                      Kevin CruijssenKevin Cruijssen

                      36.4k555192




                      36.4k555192












                      • $begingroup$
                        Are you sure that's a bug? Is it not just sorting lexicographically? ("aA" < "aa")
                        $endgroup$
                        – Shaggy
                        7 hours ago










                      • $begingroup$
                        @Shaggy You're right it's not a bug. I meant a bug in my program, not in Retina itself. It's behaving as you would expect indeed. I've edited it to 'problem'. If only I could do O$i to sort case-insensitive, just like I can List or match case-insensitive by using $i..
                        $endgroup$
                        – Kevin Cruijssen
                        7 hours ago






                      • 1




                        $begingroup$
                        @Shaggy I'm not sure if it can. Because the w and . in the O`w. were used to indicate that we're sorting pairs of characters. Not sure if we can sort every pair of characters, but only sort it based on the first character. But ah well, Martin's suggestion to sort each character based on a substitution (which is the lowercase variant of the match) works like a charm. :)
                        $endgroup$
                        – Kevin Cruijssen
                        7 hours ago






                      • 1




                        $begingroup$
                        Can it be done in 41 bytes or am I missing something?
                        $endgroup$
                        – Neil
                        5 hours ago






                      • 1




                        $begingroup$
                        github.com/m-ender/retina/wiki/The-Language#regex-modifiers
                        $endgroup$
                        – Neil
                        4 hours ago


















                      • $begingroup$
                        Are you sure that's a bug? Is it not just sorting lexicographically? ("aA" < "aa")
                        $endgroup$
                        – Shaggy
                        7 hours ago










                      • $begingroup$
                        @Shaggy You're right it's not a bug. I meant a bug in my program, not in Retina itself. It's behaving as you would expect indeed. I've edited it to 'problem'. If only I could do O$i to sort case-insensitive, just like I can List or match case-insensitive by using $i..
                        $endgroup$
                        – Kevin Cruijssen
                        7 hours ago






                      • 1




                        $begingroup$
                        @Shaggy I'm not sure if it can. Because the w and . in the O`w. were used to indicate that we're sorting pairs of characters. Not sure if we can sort every pair of characters, but only sort it based on the first character. But ah well, Martin's suggestion to sort each character based on a substitution (which is the lowercase variant of the match) works like a charm. :)
                        $endgroup$
                        – Kevin Cruijssen
                        7 hours ago






                      • 1




                        $begingroup$
                        Can it be done in 41 bytes or am I missing something?
                        $endgroup$
                        – Neil
                        5 hours ago






                      • 1




                        $begingroup$
                        github.com/m-ender/retina/wiki/The-Language#regex-modifiers
                        $endgroup$
                        – Neil
                        4 hours ago
















                      $begingroup$
                      Are you sure that's a bug? Is it not just sorting lexicographically? ("aA" < "aa")
                      $endgroup$
                      – Shaggy
                      7 hours ago




                      $begingroup$
                      Are you sure that's a bug? Is it not just sorting lexicographically? ("aA" < "aa")
                      $endgroup$
                      – Shaggy
                      7 hours ago












                      $begingroup$
                      @Shaggy You're right it's not a bug. I meant a bug in my program, not in Retina itself. It's behaving as you would expect indeed. I've edited it to 'problem'. If only I could do O$i to sort case-insensitive, just like I can List or match case-insensitive by using $i..
                      $endgroup$
                      – Kevin Cruijssen
                      7 hours ago




                      $begingroup$
                      @Shaggy You're right it's not a bug. I meant a bug in my program, not in Retina itself. It's behaving as you would expect indeed. I've edited it to 'problem'. If only I could do O$i to sort case-insensitive, just like I can List or match case-insensitive by using $i..
                      $endgroup$
                      – Kevin Cruijssen
                      7 hours ago




                      1




                      1




                      $begingroup$
                      @Shaggy I'm not sure if it can. Because the w and . in the O`w. were used to indicate that we're sorting pairs of characters. Not sure if we can sort every pair of characters, but only sort it based on the first character. But ah well, Martin's suggestion to sort each character based on a substitution (which is the lowercase variant of the match) works like a charm. :)
                      $endgroup$
                      – Kevin Cruijssen
                      7 hours ago




                      $begingroup$
                      @Shaggy I'm not sure if it can. Because the w and . in the O`w. were used to indicate that we're sorting pairs of characters. Not sure if we can sort every pair of characters, but only sort it based on the first character. But ah well, Martin's suggestion to sort each character based on a substitution (which is the lowercase variant of the match) works like a charm. :)
                      $endgroup$
                      – Kevin Cruijssen
                      7 hours ago




                      1




                      1




                      $begingroup$
                      Can it be done in 41 bytes or am I missing something?
                      $endgroup$
                      – Neil
                      5 hours ago




                      $begingroup$
                      Can it be done in 41 bytes or am I missing something?
                      $endgroup$
                      – Neil
                      5 hours ago




                      1




                      1




                      $begingroup$
                      github.com/m-ender/retina/wiki/The-Language#regex-modifiers
                      $endgroup$
                      – Neil
                      4 hours ago




                      $begingroup$
                      github.com/m-ender/retina/wiki/The-Language#regex-modifiers
                      $endgroup$
                      – Neil
                      4 hours ago











                      2












                      $begingroup$


                      Perl 6, 66 bytes





                      {[~] map {+$_~.tail},sort {+$_,.lc},values classify &lc,m:g/<:L>/}


                      Try it online!






                      share|improve this answer









                      $endgroup$


















                        2












                        $begingroup$


                        Perl 6, 66 bytes





                        {[~] map {+$_~.tail},sort {+$_,.lc},values classify &lc,m:g/<:L>/}


                        Try it online!






                        share|improve this answer









                        $endgroup$
















                          2












                          2








                          2





                          $begingroup$


                          Perl 6, 66 bytes





                          {[~] map {+$_~.tail},sort {+$_,.lc},values classify &lc,m:g/<:L>/}


                          Try it online!






                          share|improve this answer









                          $endgroup$




                          Perl 6, 66 bytes





                          {[~] map {+$_~.tail},sort {+$_,.lc},values classify &lc,m:g/<:L>/}


                          Try it online!







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 6 hours ago









                          nwellnhofnwellnhof

                          6,55511125




                          6,55511125























                              2












                              $begingroup$

                              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






                              share|improve this answer











                              $endgroup$













                              • $begingroup$
                                @+GrG1 seems to save a byte for filtering. It's also worth noting that your sorting method won't always work if a character appears 10 or more times, but that hasn't been clarified yet.
                                $endgroup$
                                – FryAmTheEggman
                                18 mins ago
















                              2












                              $begingroup$

                              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






                              share|improve this answer











                              $endgroup$













                              • $begingroup$
                                @+GrG1 seems to save a byte for filtering. It's also worth noting that your sorting method won't always work if a character appears 10 or more times, but that hasn't been clarified yet.
                                $endgroup$
                                – FryAmTheEggman
                                18 mins ago














                              2












                              2








                              2





                              $begingroup$

                              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






                              share|improve this answer











                              $endgroup$



                              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







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited 2 hours ago

























                              answered 8 hours ago









                              SokSok

                              3,627723




                              3,627723












                              • $begingroup$
                                @+GrG1 seems to save a byte for filtering. It's also worth noting that your sorting method won't always work if a character appears 10 or more times, but that hasn't been clarified yet.
                                $endgroup$
                                – FryAmTheEggman
                                18 mins ago


















                              • $begingroup$
                                @+GrG1 seems to save a byte for filtering. It's also worth noting that your sorting method won't always work if a character appears 10 or more times, but that hasn't been clarified yet.
                                $endgroup$
                                – FryAmTheEggman
                                18 mins ago
















                              $begingroup$
                              @+GrG1 seems to save a byte for filtering. It's also worth noting that your sorting method won't always work if a character appears 10 or more times, but that hasn't been clarified yet.
                              $endgroup$
                              – FryAmTheEggman
                              18 mins ago




                              $begingroup$
                              @+GrG1 seems to save a byte for filtering. It's also worth noting that your sorting method won't always work if a character appears 10 or more times, but that hasn't been clarified yet.
                              $endgroup$
                              – FryAmTheEggman
                              18 mins ago











                              1












                              $begingroup$


                              Python 2, 99 bytes





                              def f(s):a=s.lower();return''.join(sorted(`a.count(c)`+s[a.rfind(c)]for c in set(a)if c.isalpha()))


                              Try it online!






                              share|improve this answer









                              $endgroup$













                              • $begingroup$
                                The output for Database Partitions Task is not equal to 1b1D1e1k1n1o1P1r2i3s4T5a
                                $endgroup$
                                – mdahmoune
                                1 hour ago
















                              1












                              $begingroup$


                              Python 2, 99 bytes





                              def f(s):a=s.lower();return''.join(sorted(`a.count(c)`+s[a.rfind(c)]for c in set(a)if c.isalpha()))


                              Try it online!






                              share|improve this answer









                              $endgroup$













                              • $begingroup$
                                The output for Database Partitions Task is not equal to 1b1D1e1k1n1o1P1r2i3s4T5a
                                $endgroup$
                                – mdahmoune
                                1 hour ago














                              1












                              1








                              1





                              $begingroup$


                              Python 2, 99 bytes





                              def f(s):a=s.lower();return''.join(sorted(`a.count(c)`+s[a.rfind(c)]for c in set(a)if c.isalpha()))


                              Try it online!






                              share|improve this answer









                              $endgroup$




                              Python 2, 99 bytes





                              def f(s):a=s.lower();return''.join(sorted(`a.count(c)`+s[a.rfind(c)]for c in set(a)if c.isalpha()))


                              Try it online!







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered 9 hours ago









                              TFeldTFeld

                              14.5k21241




                              14.5k21241












                              • $begingroup$
                                The output for Database Partitions Task is not equal to 1b1D1e1k1n1o1P1r2i3s4T5a
                                $endgroup$
                                – mdahmoune
                                1 hour ago


















                              • $begingroup$
                                The output for Database Partitions Task is not equal to 1b1D1e1k1n1o1P1r2i3s4T5a
                                $endgroup$
                                – mdahmoune
                                1 hour ago
















                              $begingroup$
                              The output for Database Partitions Task is not equal to 1b1D1e1k1n1o1P1r2i3s4T5a
                              $endgroup$
                              – mdahmoune
                              1 hour ago




                              $begingroup$
                              The output for Database Partitions Task is not equal to 1b1D1e1k1n1o1P1r2i3s4T5a
                              $endgroup$
                              – mdahmoune
                              1 hour ago











                              1












                              $begingroup$


                              Red, 220 196 bytes



                              func[s][a: charset[#"a"-#"z"#"A"-#"Z"]rejoin sort collect[foreach c sort
                              unique reverse rejoin parse s[collect[any[keep[a]| skip]]][i: 0
                              foreach d s[if(c% 32)=(d% 32)[i: i + 1]]keep rejoin[i c]]]]


                              Try it online!






                              share|improve this answer











                              $endgroup$


















                                1












                                $begingroup$


                                Red, 220 196 bytes



                                func[s][a: charset[#"a"-#"z"#"A"-#"Z"]rejoin sort collect[foreach c sort
                                unique reverse rejoin parse s[collect[any[keep[a]| skip]]][i: 0
                                foreach d s[if(c% 32)=(d% 32)[i: i + 1]]keep rejoin[i c]]]]


                                Try it online!






                                share|improve this answer











                                $endgroup$
















                                  1












                                  1








                                  1





                                  $begingroup$


                                  Red, 220 196 bytes



                                  func[s][a: charset[#"a"-#"z"#"A"-#"Z"]rejoin sort collect[foreach c sort
                                  unique reverse rejoin parse s[collect[any[keep[a]| skip]]][i: 0
                                  foreach d s[if(c% 32)=(d% 32)[i: i + 1]]keep rejoin[i c]]]]


                                  Try it online!






                                  share|improve this answer











                                  $endgroup$




                                  Red, 220 196 bytes



                                  func[s][a: charset[#"a"-#"z"#"A"-#"Z"]rejoin sort collect[foreach c sort
                                  unique reverse rejoin parse s[collect[any[keep[a]| skip]]][i: 0
                                  foreach d s[if(c% 32)=(d% 32)[i: i + 1]]keep rejoin[i c]]]]


                                  Try it online!







                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited 8 hours ago

























                                  answered 8 hours ago









                                  Galen IvanovGalen Ivanov

                                  6,51711032




                                  6,51711032























                                      1












                                      $begingroup$

                                      Perl 5, 74 68 bytes



                                      -6 bytes changing -p to -n and using say instead of $_=join"",



                                      s/[a-z]/($h{lc$&}+=1).=$&/gie;say sort{$a-$b||lc$a cmp lc$b}values%h


                                      TIO



                                      61 bytes, in case there is no more than 9 occurence of each character



                                      s/[a-z]/($h{lc$&}+=1).=$&/gie;print sort{lc$a cmp lc$b}values%h





                                      share|improve this answer











                                      $endgroup$


















                                        1












                                        $begingroup$

                                        Perl 5, 74 68 bytes



                                        -6 bytes changing -p to -n and using say instead of $_=join"",



                                        s/[a-z]/($h{lc$&}+=1).=$&/gie;say sort{$a-$b||lc$a cmp lc$b}values%h


                                        TIO



                                        61 bytes, in case there is no more than 9 occurence of each character



                                        s/[a-z]/($h{lc$&}+=1).=$&/gie;print sort{lc$a cmp lc$b}values%h





                                        share|improve this answer











                                        $endgroup$
















                                          1












                                          1








                                          1





                                          $begingroup$

                                          Perl 5, 74 68 bytes



                                          -6 bytes changing -p to -n and using say instead of $_=join"",



                                          s/[a-z]/($h{lc$&}+=1).=$&/gie;say sort{$a-$b||lc$a cmp lc$b}values%h


                                          TIO



                                          61 bytes, in case there is no more than 9 occurence of each character



                                          s/[a-z]/($h{lc$&}+=1).=$&/gie;print sort{lc$a cmp lc$b}values%h





                                          share|improve this answer











                                          $endgroup$



                                          Perl 5, 74 68 bytes



                                          -6 bytes changing -p to -n and using say instead of $_=join"",



                                          s/[a-z]/($h{lc$&}+=1).=$&/gie;say sort{$a-$b||lc$a cmp lc$b}values%h


                                          TIO



                                          61 bytes, in case there is no more than 9 occurence of each character



                                          s/[a-z]/($h{lc$&}+=1).=$&/gie;print sort{lc$a cmp lc$b}values%h






                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited 6 hours ago

























                                          answered 8 hours ago









                                          Nahuel FouilleulNahuel Fouilleul

                                          1,67228




                                          1,67228























                                              1












                                              $begingroup$


                                              Jelly, 15 bytes



                                              fØẠµŒlĠLÞịµL,Ṫ)


                                              A full program printing the password as specified (as a monadic Link it yields a list of lists each containing an integer and a character).



                                              Try it online!






                                              share|improve this answer









                                              $endgroup$


















                                                1












                                                $begingroup$


                                                Jelly, 15 bytes



                                                fØẠµŒlĠLÞịµL,Ṫ)


                                                A full program printing the password as specified (as a monadic Link it yields a list of lists each containing an integer and a character).



                                                Try it online!






                                                share|improve this answer









                                                $endgroup$
















                                                  1












                                                  1








                                                  1





                                                  $begingroup$


                                                  Jelly, 15 bytes



                                                  fØẠµŒlĠLÞịµL,Ṫ)


                                                  A full program printing the password as specified (as a monadic Link it yields a list of lists each containing an integer and a character).



                                                  Try it online!






                                                  share|improve this answer









                                                  $endgroup$




                                                  Jelly, 15 bytes



                                                  fØẠµŒlĠLÞịµL,Ṫ)


                                                  A full program printing the password as specified (as a monadic Link it yields a list of lists each containing an integer and a character).



                                                  Try it online!







                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered 3 hours ago









                                                  Jonathan AllanJonathan Allan

                                                  51.2k534166




                                                  51.2k534166























                                                      0












                                                      $begingroup$


                                                      Charcoal, 30 bytes



                                                      F⌈Eβ№↧θιFβ¿⁼№↧θκ⊕ι⁺⊕ι§Φθ⁼↧λκ±¹


                                                      Try it online! Link is to verbose version of code. Explanation:



                                                      F⌈Eβ№↧θι


                                                      Run through the lowercase alphabet and find the highest character count in the lowercased input. Loop over the implicit range. (The loop actually goes from 0 to n-1 so I have to increment the loop variable at each use.)



                                                      Fβ


                                                      Loop over the lowercase alphabet again.



                                                      ¿⁼№↧θκ⊕ι


                                                      If the count of the current letter is equal to the outer loop value...



                                                      ⁺⊕ι§Φθ⁼↧λκ±¹


                                                      Concatenate the current count with the last occurrence of the current letter and implicitly print.






                                                      share|improve this answer









                                                      $endgroup$


















                                                        0












                                                        $begingroup$


                                                        Charcoal, 30 bytes



                                                        F⌈Eβ№↧θιFβ¿⁼№↧θκ⊕ι⁺⊕ι§Φθ⁼↧λκ±¹


                                                        Try it online! Link is to verbose version of code. Explanation:



                                                        F⌈Eβ№↧θι


                                                        Run through the lowercase alphabet and find the highest character count in the lowercased input. Loop over the implicit range. (The loop actually goes from 0 to n-1 so I have to increment the loop variable at each use.)



                                                        Fβ


                                                        Loop over the lowercase alphabet again.



                                                        ¿⁼№↧θκ⊕ι


                                                        If the count of the current letter is equal to the outer loop value...



                                                        ⁺⊕ι§Φθ⁼↧λκ±¹


                                                        Concatenate the current count with the last occurrence of the current letter and implicitly print.






                                                        share|improve this answer









                                                        $endgroup$
















                                                          0












                                                          0








                                                          0





                                                          $begingroup$


                                                          Charcoal, 30 bytes



                                                          F⌈Eβ№↧θιFβ¿⁼№↧θκ⊕ι⁺⊕ι§Φθ⁼↧λκ±¹


                                                          Try it online! Link is to verbose version of code. Explanation:



                                                          F⌈Eβ№↧θι


                                                          Run through the lowercase alphabet and find the highest character count in the lowercased input. Loop over the implicit range. (The loop actually goes from 0 to n-1 so I have to increment the loop variable at each use.)



                                                          Fβ


                                                          Loop over the lowercase alphabet again.



                                                          ¿⁼№↧θκ⊕ι


                                                          If the count of the current letter is equal to the outer loop value...



                                                          ⁺⊕ι§Φθ⁼↧λκ±¹


                                                          Concatenate the current count with the last occurrence of the current letter and implicitly print.






                                                          share|improve this answer









                                                          $endgroup$




                                                          Charcoal, 30 bytes



                                                          F⌈Eβ№↧θιFβ¿⁼№↧θκ⊕ι⁺⊕ι§Φθ⁼↧λκ±¹


                                                          Try it online! Link is to verbose version of code. Explanation:



                                                          F⌈Eβ№↧θι


                                                          Run through the lowercase alphabet and find the highest character count in the lowercased input. Loop over the implicit range. (The loop actually goes from 0 to n-1 so I have to increment the loop variable at each use.)



                                                          Fβ


                                                          Loop over the lowercase alphabet again.



                                                          ¿⁼№↧θκ⊕ι


                                                          If the count of the current letter is equal to the outer loop value...



                                                          ⁺⊕ι§Φθ⁼↧λκ±¹


                                                          Concatenate the current count with the last occurrence of the current letter and implicitly print.







                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered 4 hours ago









                                                          NeilNeil

                                                          79.9k744177




                                                          79.9k744177






























                                                              draft saved

                                                              draft discarded




















































                                                              If this is an answer to a challenge…




                                                              • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                              • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                Explanations of your answer make it more interesting to read and are very much encouraged.


                                                              • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                                              More generally…




                                                              • …Please make sure to answer the question and provide sufficient detail.


                                                              • …Avoid asking for help, clarification or responding to other answers (use comments instead).





                                                              draft saved


                                                              draft discarded














                                                              StackExchange.ready(
                                                              function () {
                                                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f178888%2fgenerate-a-password%23new-answer', 'question_page');
                                                              }
                                                              );

                                                              Post as a guest















                                                              Required, but never shown





















































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown

































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown







                                                              Popular posts from this blog

                                                              404 Error Contact Form 7 ajax form submitting

                                                              How to know if a Active Directory user can login interactively

                                                              TypeError: fit_transform() missing 1 required positional argument: 'X'