Walk Across a Keyboard











up vote
18
down vote

favorite
1












Given a word (or any sequence of letters) as input, you must interpolate between each letter such that each adjacent pair of letters in the result is also adjacent on a QWERTY keyboard, as if you typed the input by walking on a giant keyboard. For example, 'yes' might become 'ytres', 'cat' might become 'cxzawert'.



Rules:





  • This is the keyboard format you should use:



    qwertyuiop

    asdfghjkl

      zxcvbnm



    Any pair of keys which is touching in this layout is considered adjacent. For instance, 's' and 'e' are ajacent, but 's' and 'r' are not.



  • The input "word" will consist of any sequence of letters. It will have only letters, so you don't have do deal with special characters.

  • The input can be in any convenient form: stdin, a string, a list, etc. Letter case does not matter; you can take whatever is more convenient.

  • The output can be in any convenient form: stdout, a string, a list, etc. Letter case does not matter, and it does not need to be consistent.

  • Any path across the keyboard is valid, except that you cannot cross the previous letter again before getting to the next letter. For example, 'hi' could become 'hji' or 'hjnbgyui', but not 'hbhui'.

  • A letter is not ajacent with itself, so 'poll' cannot become 'poll'. Instead it would need to become something like 'polkl'.

  • No output letters are allowed before or after the word. For example, 'was' cannot become 'trewas' or 'wasdfg'.


This is code golf, the shortest answer in bytes wins.










share|improve this question






















  • So we're outputting any valid 'walk' per input? This seems like it'd be better as given two inputs, determine if it's a valid walk.
    – Veskah
    Dec 6 at 21:17










  • It seems like dewqwerty is a valid path for dy. Could you confirm that?
    – Arnauld
    Dec 6 at 21:27










  • @Arnauld yes, it is.
    – Vaelus
    Dec 6 at 21:47












  • @Veskah That's right; output any valid walk for an input. This is to allow for optimizations which might not be possible if, for instance, it had to be a shortest walk.
    – Vaelus
    Dec 6 at 21:48















up vote
18
down vote

favorite
1












Given a word (or any sequence of letters) as input, you must interpolate between each letter such that each adjacent pair of letters in the result is also adjacent on a QWERTY keyboard, as if you typed the input by walking on a giant keyboard. For example, 'yes' might become 'ytres', 'cat' might become 'cxzawert'.



Rules:





  • This is the keyboard format you should use:



    qwertyuiop

    asdfghjkl

      zxcvbnm



    Any pair of keys which is touching in this layout is considered adjacent. For instance, 's' and 'e' are ajacent, but 's' and 'r' are not.



  • The input "word" will consist of any sequence of letters. It will have only letters, so you don't have do deal with special characters.

  • The input can be in any convenient form: stdin, a string, a list, etc. Letter case does not matter; you can take whatever is more convenient.

  • The output can be in any convenient form: stdout, a string, a list, etc. Letter case does not matter, and it does not need to be consistent.

  • Any path across the keyboard is valid, except that you cannot cross the previous letter again before getting to the next letter. For example, 'hi' could become 'hji' or 'hjnbgyui', but not 'hbhui'.

  • A letter is not ajacent with itself, so 'poll' cannot become 'poll'. Instead it would need to become something like 'polkl'.

  • No output letters are allowed before or after the word. For example, 'was' cannot become 'trewas' or 'wasdfg'.


This is code golf, the shortest answer in bytes wins.










share|improve this question






















  • So we're outputting any valid 'walk' per input? This seems like it'd be better as given two inputs, determine if it's a valid walk.
    – Veskah
    Dec 6 at 21:17










  • It seems like dewqwerty is a valid path for dy. Could you confirm that?
    – Arnauld
    Dec 6 at 21:27










  • @Arnauld yes, it is.
    – Vaelus
    Dec 6 at 21:47












  • @Veskah That's right; output any valid walk for an input. This is to allow for optimizations which might not be possible if, for instance, it had to be a shortest walk.
    – Vaelus
    Dec 6 at 21:48













up vote
18
down vote

favorite
1









up vote
18
down vote

favorite
1






1





Given a word (or any sequence of letters) as input, you must interpolate between each letter such that each adjacent pair of letters in the result is also adjacent on a QWERTY keyboard, as if you typed the input by walking on a giant keyboard. For example, 'yes' might become 'ytres', 'cat' might become 'cxzawert'.



Rules:





  • This is the keyboard format you should use:



    qwertyuiop

    asdfghjkl

      zxcvbnm



    Any pair of keys which is touching in this layout is considered adjacent. For instance, 's' and 'e' are ajacent, but 's' and 'r' are not.



  • The input "word" will consist of any sequence of letters. It will have only letters, so you don't have do deal with special characters.

  • The input can be in any convenient form: stdin, a string, a list, etc. Letter case does not matter; you can take whatever is more convenient.

  • The output can be in any convenient form: stdout, a string, a list, etc. Letter case does not matter, and it does not need to be consistent.

  • Any path across the keyboard is valid, except that you cannot cross the previous letter again before getting to the next letter. For example, 'hi' could become 'hji' or 'hjnbgyui', but not 'hbhui'.

  • A letter is not ajacent with itself, so 'poll' cannot become 'poll'. Instead it would need to become something like 'polkl'.

  • No output letters are allowed before or after the word. For example, 'was' cannot become 'trewas' or 'wasdfg'.


This is code golf, the shortest answer in bytes wins.










share|improve this question













Given a word (or any sequence of letters) as input, you must interpolate between each letter such that each adjacent pair of letters in the result is also adjacent on a QWERTY keyboard, as if you typed the input by walking on a giant keyboard. For example, 'yes' might become 'ytres', 'cat' might become 'cxzawert'.



Rules:





  • This is the keyboard format you should use:



    qwertyuiop

    asdfghjkl

      zxcvbnm



    Any pair of keys which is touching in this layout is considered adjacent. For instance, 's' and 'e' are ajacent, but 's' and 'r' are not.



  • The input "word" will consist of any sequence of letters. It will have only letters, so you don't have do deal with special characters.

  • The input can be in any convenient form: stdin, a string, a list, etc. Letter case does not matter; you can take whatever is more convenient.

  • The output can be in any convenient form: stdout, a string, a list, etc. Letter case does not matter, and it does not need to be consistent.

  • Any path across the keyboard is valid, except that you cannot cross the previous letter again before getting to the next letter. For example, 'hi' could become 'hji' or 'hjnbgyui', but not 'hbhui'.

  • A letter is not ajacent with itself, so 'poll' cannot become 'poll'. Instead it would need to become something like 'polkl'.

  • No output letters are allowed before or after the word. For example, 'was' cannot become 'trewas' or 'wasdfg'.


This is code golf, the shortest answer in bytes wins.







code-golf keyboard






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 6 at 21:08









Vaelus

280112




280112












  • So we're outputting any valid 'walk' per input? This seems like it'd be better as given two inputs, determine if it's a valid walk.
    – Veskah
    Dec 6 at 21:17










  • It seems like dewqwerty is a valid path for dy. Could you confirm that?
    – Arnauld
    Dec 6 at 21:27










  • @Arnauld yes, it is.
    – Vaelus
    Dec 6 at 21:47












  • @Veskah That's right; output any valid walk for an input. This is to allow for optimizations which might not be possible if, for instance, it had to be a shortest walk.
    – Vaelus
    Dec 6 at 21:48


















  • So we're outputting any valid 'walk' per input? This seems like it'd be better as given two inputs, determine if it's a valid walk.
    – Veskah
    Dec 6 at 21:17










  • It seems like dewqwerty is a valid path for dy. Could you confirm that?
    – Arnauld
    Dec 6 at 21:27










  • @Arnauld yes, it is.
    – Vaelus
    Dec 6 at 21:47












  • @Veskah That's right; output any valid walk for an input. This is to allow for optimizations which might not be possible if, for instance, it had to be a shortest walk.
    – Vaelus
    Dec 6 at 21:48
















So we're outputting any valid 'walk' per input? This seems like it'd be better as given two inputs, determine if it's a valid walk.
– Veskah
Dec 6 at 21:17




So we're outputting any valid 'walk' per input? This seems like it'd be better as given two inputs, determine if it's a valid walk.
– Veskah
Dec 6 at 21:17












It seems like dewqwerty is a valid path for dy. Could you confirm that?
– Arnauld
Dec 6 at 21:27




It seems like dewqwerty is a valid path for dy. Could you confirm that?
– Arnauld
Dec 6 at 21:27












@Arnauld yes, it is.
– Vaelus
Dec 6 at 21:47






@Arnauld yes, it is.
– Vaelus
Dec 6 at 21:47














@Veskah That's right; output any valid walk for an input. This is to allow for optimizations which might not be possible if, for instance, it had to be a shortest walk.
– Vaelus
Dec 6 at 21:48




@Veskah That's right; output any valid walk for an input. This is to allow for optimizations which might not be possible if, for instance, it had to be a shortest walk.
– Vaelus
Dec 6 at 21:48










6 Answers
6






active

oldest

votes

















up vote
12
down vote














Python 2, 83 bytes





lambda s:re.findall('.*?'.join(s),'qwertyuioplkmnjhbvgfcxdsza'*len(s))[0]
import re


Try it online!



Walks the entire keyboard until the word is written.






share|improve this answer

















  • 2




    How come the import re comes after the code, not before?
    – BruceWayne
    2 days ago










  • @BruceWayne The re.findall would be evaluated when the lambda runs, so importing after the lambda's definition is ok. That being said, it is clearer to import before, there's just no need to
    – pushkin
    2 days ago










  • @pushkin ah, I didn't know that thanks for clarifying! Did you import after just as a personal preference/choice or does it help with byte count at all?
    – BruceWayne
    2 days ago








  • 2




    @BruceWayne It's a bit of a convention for this forum. It's just so that it works with the way the TiO site organizes the code. Try clicking on the "Try it online!" link to see what I mean.
    – mypetlion
    2 days ago


















up vote
6
down vote














Python 2, 300 bytes (optimal solution)




302 308 315 319 324 327 328 430 432 bytes



-4 bytes thanks to mypetlion





from networkx import*
i,q=input(),' '*12
M,j,z=q+'qwertyuiop asdfghjkl zxcvbnm'+q,1,i[:1]
G=from_edgelist([(M[e],M[e+h])for h in[-1,1,11,12,-11,-12]for e in range(44)if' '!=M[e]and' '!=M[e+h]])
while j<len(i):
y=i[j-1]
if y==i[j]:i[j:j]=list(G[y])[0]
z+=shortest_path(G,y,i[j])[1:];j+=1
print z


Try it online!



This solution gives the shortest possible output. The keyboard is transformed into a graph used to find the shortest path to compute the output string:



puzzles     --> poiuhbvcxzazxcvbhjklkiuytres
programming --> poiuytrtyuioijhgtresasdcvbnmkmkijnbg
code --> cvbhjioijhgfde
golf --> ghjiolkjhgf
yes --> ytres
hi --> hji
poll --> polpl





share|improve this answer






























    up vote
    5
    down vote














    Japt -g, 23 bytes



    ;D·ÎÔ+D·Årí)pUl)fUq".*?


    Try it online!



    Takes input as an array of capital letters. Very similar to the other answers otherwise.



    Explanation:



    ;                          :Set D to the keyboard layout
    D·Î :Get the first row of keys
    Ô :Reversed
    + :Concat
    D·Å :The other two rows
    rí) :Interleaved
    p :Repeat that string
    Ul) : A number of times equal to the length of the input
    f :Get the substrings that match
    U : The input
    q".*? : joined with ".*?"
    :Implicitly output just once of the matches





    share|improve this answer






























      up vote
      3
      down vote













      JavaScript (ES6), 70 bytes



      Same strategy as TFeld.





      s=>'qazsxdcfvgbhnjmklpoiuytrew'.repeat(s.length).match(s.join`.*?`)[0]


      Try it online!






      share|improve this answer




























        up vote
        2
        down vote














        05AB1E, 43 bytes



        ü)Jε©žVćRs`.ιJ«D«Œʒg≠yн®нQyθ®θQ**}yªн¨}JIθ«


        Not the right language for this challenge, since it cannot use regex like the other answers did..



        Try it online or verify all test cases.



        Explanation:





        ü)               # Split the input into overlapping pairs
        # i.e. "poll" → ["p","o"],["o","l"],["l","l"]]
        J # Join each inner list together
        # i.e. ["p","o"],["o","l"],["l","l"]] → ["po","ol","ll"]
        ε # Map each to:
        © # Store the current value in the register
        žV # Push ["qwertyuiop","asdfghjkl","zxcvbnm"]
        ćR # Extract the head, and reverse it
        # i.e. ["qwertyuiop","asdfghjkl","zxcvbnm"] → "poiuytrewq"
        s` # Swap to take the remainder, and push them to the stack
        .ι # And then interweave them with each other
        # i.e. ["asdfghjkl","zxcvbnm"]
        # → ["a","z","s","x","d","c","f","v","g","b","h","n","j","m","k","l"]
        J # Join the list to a single string
        # i.e. → "azsxdcfvgbhnjmkl"
        « # Merge them together
        # i.e. "qwertyuiop" and "azsxdcfvgbhnjmkl"
        # → "poiuytrewqazsxdcfvgbhnjmkl"
        D« # Duplicate it, and append it to itself
        # i.e. "poiuytrewqazsxdcfvgbhnjmkl"
        # → "poiuytrewqazsxdcfvgbhnjmklpoiuytrewqazsxdcfvgbhnjmkl"
        Π# Get all substrings of this strings
        # i.e. → ["p","po","poi",...,"k","kl","l"]
        ʒ } # Filter this list by:
        g≠ # Where the length is NOT 1 (otherwise pair "ll" would result in "l")
        * # and
        yн®нQ # Where the first character of the substring and pair are the same
        * # and
        yθ®θQ # Where the last character of the substring and pair are the same
        # i.e. "po" →
        # i.e. "ll" → ["lazsxdcfvgbhnjmkl"]
        yª # After filtering, append the current pair to the filtered list
        # i.e. → ["po"]
        # i.e. ["lazsxdcfvgbhnjmkl"] → ["lazsxdcfvgbhnjmkl","ll"]
        н # Get the first item
        # ["po"] → "po"
        # ["lazsxdcfvgbhnjmkl","ll"] → "lazsxdcfvgbhnjmkl"
        ¨ # Remove the last character
        # i.e. "po" → "p"
        # i.e. "lazsxdcfvgbhnjmkl" → "lazsxdcfvgbhnjmk"
        } # Close the map
        J # Join everything together
        # i.e. ["p","o","lazsxdcfvgbhnjmk"] → "polazsxdcfvgbhnjmk"
        Iθ« # And append the last character of the input
        # (and output the result implicitly)
        # i.e. "polazsxdcfvgbhnjmk" and "poll" → "polazsxdcfvgbhnjmkl"





        share|improve this answer




























          up vote
          2
          down vote














          Charcoal, 48 bytes



          ≔”&⌈″⌊5EWXVNa…-εW¶ζR”η≔⌕η§θ⁰ζFθF⊕﹪⁻⌕ηιζ²⁶«§ηζ≦⊕ζ


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



          ≔”&⌈″⌊5EWXVNa…-εW¶ζR”η


          Get the string qwertyuioplkmjnhbgvfcdxsza.



          ≔⌕η§θ⁰ζ


          Find the position of the first character of the word. This index is normally one past the character just reached, but this value fakes out the first iteration of the loop to print the first character of the word.



          Fθ


          Loop over each character.



          F⊕﹪⁻⌕ηιζ²⁶«


          Compute how many characters to print to include the next character of the word and loop that many times.



          §ηζ≦⊕ζ


          Print the next character cyclically indexed and increment the index.






          share|improve this answer





















          • Have you tried rotating the string “qwertyuioplkmjnhbgvfcdxsza” and seeing if any of the rotations happen to be more compressible? I'm not familiar with charcoal's compression; maybe this isn't possible.
            – Vaelus
            2 days ago












          • @Vaelus I don't know either so I tried all 26 rotations but they all compress to 20 bytes. Of course, those aren't all of the possible walks...
            – Neil
            2 days ago











          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',
          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%2f177096%2fwalk-across-a-keyboard%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          6 Answers
          6






          active

          oldest

          votes








          6 Answers
          6






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          12
          down vote














          Python 2, 83 bytes





          lambda s:re.findall('.*?'.join(s),'qwertyuioplkmnjhbvgfcxdsza'*len(s))[0]
          import re


          Try it online!



          Walks the entire keyboard until the word is written.






          share|improve this answer

















          • 2




            How come the import re comes after the code, not before?
            – BruceWayne
            2 days ago










          • @BruceWayne The re.findall would be evaluated when the lambda runs, so importing after the lambda's definition is ok. That being said, it is clearer to import before, there's just no need to
            – pushkin
            2 days ago










          • @pushkin ah, I didn't know that thanks for clarifying! Did you import after just as a personal preference/choice or does it help with byte count at all?
            – BruceWayne
            2 days ago








          • 2




            @BruceWayne It's a bit of a convention for this forum. It's just so that it works with the way the TiO site organizes the code. Try clicking on the "Try it online!" link to see what I mean.
            – mypetlion
            2 days ago















          up vote
          12
          down vote














          Python 2, 83 bytes





          lambda s:re.findall('.*?'.join(s),'qwertyuioplkmnjhbvgfcxdsza'*len(s))[0]
          import re


          Try it online!



          Walks the entire keyboard until the word is written.






          share|improve this answer

















          • 2




            How come the import re comes after the code, not before?
            – BruceWayne
            2 days ago










          • @BruceWayne The re.findall would be evaluated when the lambda runs, so importing after the lambda's definition is ok. That being said, it is clearer to import before, there's just no need to
            – pushkin
            2 days ago










          • @pushkin ah, I didn't know that thanks for clarifying! Did you import after just as a personal preference/choice or does it help with byte count at all?
            – BruceWayne
            2 days ago








          • 2




            @BruceWayne It's a bit of a convention for this forum. It's just so that it works with the way the TiO site organizes the code. Try clicking on the "Try it online!" link to see what I mean.
            – mypetlion
            2 days ago













          up vote
          12
          down vote










          up vote
          12
          down vote










          Python 2, 83 bytes





          lambda s:re.findall('.*?'.join(s),'qwertyuioplkmnjhbvgfcxdsza'*len(s))[0]
          import re


          Try it online!



          Walks the entire keyboard until the word is written.






          share|improve this answer













          Python 2, 83 bytes





          lambda s:re.findall('.*?'.join(s),'qwertyuioplkmnjhbvgfcxdsza'*len(s))[0]
          import re


          Try it online!



          Walks the entire keyboard until the word is written.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 6 at 21:33









          TFeld

          13.9k21240




          13.9k21240








          • 2




            How come the import re comes after the code, not before?
            – BruceWayne
            2 days ago










          • @BruceWayne The re.findall would be evaluated when the lambda runs, so importing after the lambda's definition is ok. That being said, it is clearer to import before, there's just no need to
            – pushkin
            2 days ago










          • @pushkin ah, I didn't know that thanks for clarifying! Did you import after just as a personal preference/choice or does it help with byte count at all?
            – BruceWayne
            2 days ago








          • 2




            @BruceWayne It's a bit of a convention for this forum. It's just so that it works with the way the TiO site organizes the code. Try clicking on the "Try it online!" link to see what I mean.
            – mypetlion
            2 days ago














          • 2




            How come the import re comes after the code, not before?
            – BruceWayne
            2 days ago










          • @BruceWayne The re.findall would be evaluated when the lambda runs, so importing after the lambda's definition is ok. That being said, it is clearer to import before, there's just no need to
            – pushkin
            2 days ago










          • @pushkin ah, I didn't know that thanks for clarifying! Did you import after just as a personal preference/choice or does it help with byte count at all?
            – BruceWayne
            2 days ago








          • 2




            @BruceWayne It's a bit of a convention for this forum. It's just so that it works with the way the TiO site organizes the code. Try clicking on the "Try it online!" link to see what I mean.
            – mypetlion
            2 days ago








          2




          2




          How come the import re comes after the code, not before?
          – BruceWayne
          2 days ago




          How come the import re comes after the code, not before?
          – BruceWayne
          2 days ago












          @BruceWayne The re.findall would be evaluated when the lambda runs, so importing after the lambda's definition is ok. That being said, it is clearer to import before, there's just no need to
          – pushkin
          2 days ago




          @BruceWayne The re.findall would be evaluated when the lambda runs, so importing after the lambda's definition is ok. That being said, it is clearer to import before, there's just no need to
          – pushkin
          2 days ago












          @pushkin ah, I didn't know that thanks for clarifying! Did you import after just as a personal preference/choice or does it help with byte count at all?
          – BruceWayne
          2 days ago






          @pushkin ah, I didn't know that thanks for clarifying! Did you import after just as a personal preference/choice or does it help with byte count at all?
          – BruceWayne
          2 days ago






          2




          2




          @BruceWayne It's a bit of a convention for this forum. It's just so that it works with the way the TiO site organizes the code. Try clicking on the "Try it online!" link to see what I mean.
          – mypetlion
          2 days ago




          @BruceWayne It's a bit of a convention for this forum. It's just so that it works with the way the TiO site organizes the code. Try clicking on the "Try it online!" link to see what I mean.
          – mypetlion
          2 days ago










          up vote
          6
          down vote














          Python 2, 300 bytes (optimal solution)




          302 308 315 319 324 327 328 430 432 bytes



          -4 bytes thanks to mypetlion





          from networkx import*
          i,q=input(),' '*12
          M,j,z=q+'qwertyuiop asdfghjkl zxcvbnm'+q,1,i[:1]
          G=from_edgelist([(M[e],M[e+h])for h in[-1,1,11,12,-11,-12]for e in range(44)if' '!=M[e]and' '!=M[e+h]])
          while j<len(i):
          y=i[j-1]
          if y==i[j]:i[j:j]=list(G[y])[0]
          z+=shortest_path(G,y,i[j])[1:];j+=1
          print z


          Try it online!



          This solution gives the shortest possible output. The keyboard is transformed into a graph used to find the shortest path to compute the output string:



          puzzles     --> poiuhbvcxzazxcvbhjklkiuytres
          programming --> poiuytrtyuioijhgtresasdcvbnmkmkijnbg
          code --> cvbhjioijhgfde
          golf --> ghjiolkjhgf
          yes --> ytres
          hi --> hji
          poll --> polpl





          share|improve this answer



























            up vote
            6
            down vote














            Python 2, 300 bytes (optimal solution)




            302 308 315 319 324 327 328 430 432 bytes



            -4 bytes thanks to mypetlion





            from networkx import*
            i,q=input(),' '*12
            M,j,z=q+'qwertyuiop asdfghjkl zxcvbnm'+q,1,i[:1]
            G=from_edgelist([(M[e],M[e+h])for h in[-1,1,11,12,-11,-12]for e in range(44)if' '!=M[e]and' '!=M[e+h]])
            while j<len(i):
            y=i[j-1]
            if y==i[j]:i[j:j]=list(G[y])[0]
            z+=shortest_path(G,y,i[j])[1:];j+=1
            print z


            Try it online!



            This solution gives the shortest possible output. The keyboard is transformed into a graph used to find the shortest path to compute the output string:



            puzzles     --> poiuhbvcxzazxcvbhjklkiuytres
            programming --> poiuytrtyuioijhgtresasdcvbnmkmkijnbg
            code --> cvbhjioijhgfde
            golf --> ghjiolkjhgf
            yes --> ytres
            hi --> hji
            poll --> polpl





            share|improve this answer

























              up vote
              6
              down vote










              up vote
              6
              down vote










              Python 2, 300 bytes (optimal solution)




              302 308 315 319 324 327 328 430 432 bytes



              -4 bytes thanks to mypetlion





              from networkx import*
              i,q=input(),' '*12
              M,j,z=q+'qwertyuiop asdfghjkl zxcvbnm'+q,1,i[:1]
              G=from_edgelist([(M[e],M[e+h])for h in[-1,1,11,12,-11,-12]for e in range(44)if' '!=M[e]and' '!=M[e+h]])
              while j<len(i):
              y=i[j-1]
              if y==i[j]:i[j:j]=list(G[y])[0]
              z+=shortest_path(G,y,i[j])[1:];j+=1
              print z


              Try it online!



              This solution gives the shortest possible output. The keyboard is transformed into a graph used to find the shortest path to compute the output string:



              puzzles     --> poiuhbvcxzazxcvbhjklkiuytres
              programming --> poiuytrtyuioijhgtresasdcvbnmkmkijnbg
              code --> cvbhjioijhgfde
              golf --> ghjiolkjhgf
              yes --> ytres
              hi --> hji
              poll --> polpl





              share|improve this answer















              Python 2, 300 bytes (optimal solution)




              302 308 315 319 324 327 328 430 432 bytes



              -4 bytes thanks to mypetlion





              from networkx import*
              i,q=input(),' '*12
              M,j,z=q+'qwertyuiop asdfghjkl zxcvbnm'+q,1,i[:1]
              G=from_edgelist([(M[e],M[e+h])for h in[-1,1,11,12,-11,-12]for e in range(44)if' '!=M[e]and' '!=M[e+h]])
              while j<len(i):
              y=i[j-1]
              if y==i[j]:i[j:j]=list(G[y])[0]
              z+=shortest_path(G,y,i[j])[1:];j+=1
              print z


              Try it online!



              This solution gives the shortest possible output. The keyboard is transformed into a graph used to find the shortest path to compute the output string:



              puzzles     --> poiuhbvcxzazxcvbhjklkiuytres
              programming --> poiuytrtyuioijhgtresasdcvbnmkmkijnbg
              code --> cvbhjioijhgfde
              golf --> ghjiolkjhgf
              yes --> ytres
              hi --> hji
              poll --> polpl






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited 2 days ago

























              answered 2 days ago









              mdahmoune

              1,4201723




              1,4201723






















                  up vote
                  5
                  down vote














                  Japt -g, 23 bytes



                  ;D·ÎÔ+D·Årí)pUl)fUq".*?


                  Try it online!



                  Takes input as an array of capital letters. Very similar to the other answers otherwise.



                  Explanation:



                  ;                          :Set D to the keyboard layout
                  D·Î :Get the first row of keys
                  Ô :Reversed
                  + :Concat
                  D·Å :The other two rows
                  rí) :Interleaved
                  p :Repeat that string
                  Ul) : A number of times equal to the length of the input
                  f :Get the substrings that match
                  U : The input
                  q".*? : joined with ".*?"
                  :Implicitly output just once of the matches





                  share|improve this answer



























                    up vote
                    5
                    down vote














                    Japt -g, 23 bytes



                    ;D·ÎÔ+D·Årí)pUl)fUq".*?


                    Try it online!



                    Takes input as an array of capital letters. Very similar to the other answers otherwise.



                    Explanation:



                    ;                          :Set D to the keyboard layout
                    D·Î :Get the first row of keys
                    Ô :Reversed
                    + :Concat
                    D·Å :The other two rows
                    rí) :Interleaved
                    p :Repeat that string
                    Ul) : A number of times equal to the length of the input
                    f :Get the substrings that match
                    U : The input
                    q".*? : joined with ".*?"
                    :Implicitly output just once of the matches





                    share|improve this answer

























                      up vote
                      5
                      down vote










                      up vote
                      5
                      down vote










                      Japt -g, 23 bytes



                      ;D·ÎÔ+D·Årí)pUl)fUq".*?


                      Try it online!



                      Takes input as an array of capital letters. Very similar to the other answers otherwise.



                      Explanation:



                      ;                          :Set D to the keyboard layout
                      D·Î :Get the first row of keys
                      Ô :Reversed
                      + :Concat
                      D·Å :The other two rows
                      rí) :Interleaved
                      p :Repeat that string
                      Ul) : A number of times equal to the length of the input
                      f :Get the substrings that match
                      U : The input
                      q".*? : joined with ".*?"
                      :Implicitly output just once of the matches





                      share|improve this answer















                      Japt -g, 23 bytes



                      ;D·ÎÔ+D·Årí)pUl)fUq".*?


                      Try it online!



                      Takes input as an array of capital letters. Very similar to the other answers otherwise.



                      Explanation:



                      ;                          :Set D to the keyboard layout
                      D·Î :Get the first row of keys
                      Ô :Reversed
                      + :Concat
                      D·Å :The other two rows
                      rí) :Interleaved
                      p :Repeat that string
                      Ul) : A number of times equal to the length of the input
                      f :Get the substrings that match
                      U : The input
                      q".*? : joined with ".*?"
                      :Implicitly output just once of the matches






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Dec 7 at 4:48

























                      answered Dec 7 at 1:21









                      Kamil Drakari

                      2,776416




                      2,776416






















                          up vote
                          3
                          down vote













                          JavaScript (ES6), 70 bytes



                          Same strategy as TFeld.





                          s=>'qazsxdcfvgbhnjmklpoiuytrew'.repeat(s.length).match(s.join`.*?`)[0]


                          Try it online!






                          share|improve this answer

























                            up vote
                            3
                            down vote













                            JavaScript (ES6), 70 bytes



                            Same strategy as TFeld.





                            s=>'qazsxdcfvgbhnjmklpoiuytrew'.repeat(s.length).match(s.join`.*?`)[0]


                            Try it online!






                            share|improve this answer























                              up vote
                              3
                              down vote










                              up vote
                              3
                              down vote









                              JavaScript (ES6), 70 bytes



                              Same strategy as TFeld.





                              s=>'qazsxdcfvgbhnjmklpoiuytrew'.repeat(s.length).match(s.join`.*?`)[0]


                              Try it online!






                              share|improve this answer












                              JavaScript (ES6), 70 bytes



                              Same strategy as TFeld.





                              s=>'qazsxdcfvgbhnjmklpoiuytrew'.repeat(s.length).match(s.join`.*?`)[0]


                              Try it online!







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Dec 6 at 23:45









                              Arnauld

                              70.8k688298




                              70.8k688298






















                                  up vote
                                  2
                                  down vote














                                  05AB1E, 43 bytes



                                  ü)Jε©žVćRs`.ιJ«D«Œʒg≠yн®нQyθ®θQ**}yªн¨}JIθ«


                                  Not the right language for this challenge, since it cannot use regex like the other answers did..



                                  Try it online or verify all test cases.



                                  Explanation:





                                  ü)               # Split the input into overlapping pairs
                                  # i.e. "poll" → ["p","o"],["o","l"],["l","l"]]
                                  J # Join each inner list together
                                  # i.e. ["p","o"],["o","l"],["l","l"]] → ["po","ol","ll"]
                                  ε # Map each to:
                                  © # Store the current value in the register
                                  žV # Push ["qwertyuiop","asdfghjkl","zxcvbnm"]
                                  ćR # Extract the head, and reverse it
                                  # i.e. ["qwertyuiop","asdfghjkl","zxcvbnm"] → "poiuytrewq"
                                  s` # Swap to take the remainder, and push them to the stack
                                  .ι # And then interweave them with each other
                                  # i.e. ["asdfghjkl","zxcvbnm"]
                                  # → ["a","z","s","x","d","c","f","v","g","b","h","n","j","m","k","l"]
                                  J # Join the list to a single string
                                  # i.e. → "azsxdcfvgbhnjmkl"
                                  « # Merge them together
                                  # i.e. "qwertyuiop" and "azsxdcfvgbhnjmkl"
                                  # → "poiuytrewqazsxdcfvgbhnjmkl"
                                  D« # Duplicate it, and append it to itself
                                  # i.e. "poiuytrewqazsxdcfvgbhnjmkl"
                                  # → "poiuytrewqazsxdcfvgbhnjmklpoiuytrewqazsxdcfvgbhnjmkl"
                                  Π# Get all substrings of this strings
                                  # i.e. → ["p","po","poi",...,"k","kl","l"]
                                  ʒ } # Filter this list by:
                                  g≠ # Where the length is NOT 1 (otherwise pair "ll" would result in "l")
                                  * # and
                                  yн®нQ # Where the first character of the substring and pair are the same
                                  * # and
                                  yθ®θQ # Where the last character of the substring and pair are the same
                                  # i.e. "po" →
                                  # i.e. "ll" → ["lazsxdcfvgbhnjmkl"]
                                  yª # After filtering, append the current pair to the filtered list
                                  # i.e. → ["po"]
                                  # i.e. ["lazsxdcfvgbhnjmkl"] → ["lazsxdcfvgbhnjmkl","ll"]
                                  н # Get the first item
                                  # ["po"] → "po"
                                  # ["lazsxdcfvgbhnjmkl","ll"] → "lazsxdcfvgbhnjmkl"
                                  ¨ # Remove the last character
                                  # i.e. "po" → "p"
                                  # i.e. "lazsxdcfvgbhnjmkl" → "lazsxdcfvgbhnjmk"
                                  } # Close the map
                                  J # Join everything together
                                  # i.e. ["p","o","lazsxdcfvgbhnjmk"] → "polazsxdcfvgbhnjmk"
                                  Iθ« # And append the last character of the input
                                  # (and output the result implicitly)
                                  # i.e. "polazsxdcfvgbhnjmk" and "poll" → "polazsxdcfvgbhnjmkl"





                                  share|improve this answer

























                                    up vote
                                    2
                                    down vote














                                    05AB1E, 43 bytes



                                    ü)Jε©žVćRs`.ιJ«D«Œʒg≠yн®нQyθ®θQ**}yªн¨}JIθ«


                                    Not the right language for this challenge, since it cannot use regex like the other answers did..



                                    Try it online or verify all test cases.



                                    Explanation:





                                    ü)               # Split the input into overlapping pairs
                                    # i.e. "poll" → ["p","o"],["o","l"],["l","l"]]
                                    J # Join each inner list together
                                    # i.e. ["p","o"],["o","l"],["l","l"]] → ["po","ol","ll"]
                                    ε # Map each to:
                                    © # Store the current value in the register
                                    žV # Push ["qwertyuiop","asdfghjkl","zxcvbnm"]
                                    ćR # Extract the head, and reverse it
                                    # i.e. ["qwertyuiop","asdfghjkl","zxcvbnm"] → "poiuytrewq"
                                    s` # Swap to take the remainder, and push them to the stack
                                    .ι # And then interweave them with each other
                                    # i.e. ["asdfghjkl","zxcvbnm"]
                                    # → ["a","z","s","x","d","c","f","v","g","b","h","n","j","m","k","l"]
                                    J # Join the list to a single string
                                    # i.e. → "azsxdcfvgbhnjmkl"
                                    « # Merge them together
                                    # i.e. "qwertyuiop" and "azsxdcfvgbhnjmkl"
                                    # → "poiuytrewqazsxdcfvgbhnjmkl"
                                    D« # Duplicate it, and append it to itself
                                    # i.e. "poiuytrewqazsxdcfvgbhnjmkl"
                                    # → "poiuytrewqazsxdcfvgbhnjmklpoiuytrewqazsxdcfvgbhnjmkl"
                                    Π# Get all substrings of this strings
                                    # i.e. → ["p","po","poi",...,"k","kl","l"]
                                    ʒ } # Filter this list by:
                                    g≠ # Where the length is NOT 1 (otherwise pair "ll" would result in "l")
                                    * # and
                                    yн®нQ # Where the first character of the substring and pair are the same
                                    * # and
                                    yθ®θQ # Where the last character of the substring and pair are the same
                                    # i.e. "po" →
                                    # i.e. "ll" → ["lazsxdcfvgbhnjmkl"]
                                    yª # After filtering, append the current pair to the filtered list
                                    # i.e. → ["po"]
                                    # i.e. ["lazsxdcfvgbhnjmkl"] → ["lazsxdcfvgbhnjmkl","ll"]
                                    н # Get the first item
                                    # ["po"] → "po"
                                    # ["lazsxdcfvgbhnjmkl","ll"] → "lazsxdcfvgbhnjmkl"
                                    ¨ # Remove the last character
                                    # i.e. "po" → "p"
                                    # i.e. "lazsxdcfvgbhnjmkl" → "lazsxdcfvgbhnjmk"
                                    } # Close the map
                                    J # Join everything together
                                    # i.e. ["p","o","lazsxdcfvgbhnjmk"] → "polazsxdcfvgbhnjmk"
                                    Iθ« # And append the last character of the input
                                    # (and output the result implicitly)
                                    # i.e. "polazsxdcfvgbhnjmk" and "poll" → "polazsxdcfvgbhnjmkl"





                                    share|improve this answer























                                      up vote
                                      2
                                      down vote










                                      up vote
                                      2
                                      down vote










                                      05AB1E, 43 bytes



                                      ü)Jε©žVćRs`.ιJ«D«Œʒg≠yн®нQyθ®θQ**}yªн¨}JIθ«


                                      Not the right language for this challenge, since it cannot use regex like the other answers did..



                                      Try it online or verify all test cases.



                                      Explanation:





                                      ü)               # Split the input into overlapping pairs
                                      # i.e. "poll" → ["p","o"],["o","l"],["l","l"]]
                                      J # Join each inner list together
                                      # i.e. ["p","o"],["o","l"],["l","l"]] → ["po","ol","ll"]
                                      ε # Map each to:
                                      © # Store the current value in the register
                                      žV # Push ["qwertyuiop","asdfghjkl","zxcvbnm"]
                                      ćR # Extract the head, and reverse it
                                      # i.e. ["qwertyuiop","asdfghjkl","zxcvbnm"] → "poiuytrewq"
                                      s` # Swap to take the remainder, and push them to the stack
                                      .ι # And then interweave them with each other
                                      # i.e. ["asdfghjkl","zxcvbnm"]
                                      # → ["a","z","s","x","d","c","f","v","g","b","h","n","j","m","k","l"]
                                      J # Join the list to a single string
                                      # i.e. → "azsxdcfvgbhnjmkl"
                                      « # Merge them together
                                      # i.e. "qwertyuiop" and "azsxdcfvgbhnjmkl"
                                      # → "poiuytrewqazsxdcfvgbhnjmkl"
                                      D« # Duplicate it, and append it to itself
                                      # i.e. "poiuytrewqazsxdcfvgbhnjmkl"
                                      # → "poiuytrewqazsxdcfvgbhnjmklpoiuytrewqazsxdcfvgbhnjmkl"
                                      Π# Get all substrings of this strings
                                      # i.e. → ["p","po","poi",...,"k","kl","l"]
                                      ʒ } # Filter this list by:
                                      g≠ # Where the length is NOT 1 (otherwise pair "ll" would result in "l")
                                      * # and
                                      yн®нQ # Where the first character of the substring and pair are the same
                                      * # and
                                      yθ®θQ # Where the last character of the substring and pair are the same
                                      # i.e. "po" →
                                      # i.e. "ll" → ["lazsxdcfvgbhnjmkl"]
                                      yª # After filtering, append the current pair to the filtered list
                                      # i.e. → ["po"]
                                      # i.e. ["lazsxdcfvgbhnjmkl"] → ["lazsxdcfvgbhnjmkl","ll"]
                                      н # Get the first item
                                      # ["po"] → "po"
                                      # ["lazsxdcfvgbhnjmkl","ll"] → "lazsxdcfvgbhnjmkl"
                                      ¨ # Remove the last character
                                      # i.e. "po" → "p"
                                      # i.e. "lazsxdcfvgbhnjmkl" → "lazsxdcfvgbhnjmk"
                                      } # Close the map
                                      J # Join everything together
                                      # i.e. ["p","o","lazsxdcfvgbhnjmk"] → "polazsxdcfvgbhnjmk"
                                      Iθ« # And append the last character of the input
                                      # (and output the result implicitly)
                                      # i.e. "polazsxdcfvgbhnjmk" and "poll" → "polazsxdcfvgbhnjmkl"





                                      share|improve this answer













                                      05AB1E, 43 bytes



                                      ü)Jε©žVćRs`.ιJ«D«Œʒg≠yн®нQyθ®θQ**}yªн¨}JIθ«


                                      Not the right language for this challenge, since it cannot use regex like the other answers did..



                                      Try it online or verify all test cases.



                                      Explanation:





                                      ü)               # Split the input into overlapping pairs
                                      # i.e. "poll" → ["p","o"],["o","l"],["l","l"]]
                                      J # Join each inner list together
                                      # i.e. ["p","o"],["o","l"],["l","l"]] → ["po","ol","ll"]
                                      ε # Map each to:
                                      © # Store the current value in the register
                                      žV # Push ["qwertyuiop","asdfghjkl","zxcvbnm"]
                                      ćR # Extract the head, and reverse it
                                      # i.e. ["qwertyuiop","asdfghjkl","zxcvbnm"] → "poiuytrewq"
                                      s` # Swap to take the remainder, and push them to the stack
                                      .ι # And then interweave them with each other
                                      # i.e. ["asdfghjkl","zxcvbnm"]
                                      # → ["a","z","s","x","d","c","f","v","g","b","h","n","j","m","k","l"]
                                      J # Join the list to a single string
                                      # i.e. → "azsxdcfvgbhnjmkl"
                                      « # Merge them together
                                      # i.e. "qwertyuiop" and "azsxdcfvgbhnjmkl"
                                      # → "poiuytrewqazsxdcfvgbhnjmkl"
                                      D« # Duplicate it, and append it to itself
                                      # i.e. "poiuytrewqazsxdcfvgbhnjmkl"
                                      # → "poiuytrewqazsxdcfvgbhnjmklpoiuytrewqazsxdcfvgbhnjmkl"
                                      Π# Get all substrings of this strings
                                      # i.e. → ["p","po","poi",...,"k","kl","l"]
                                      ʒ } # Filter this list by:
                                      g≠ # Where the length is NOT 1 (otherwise pair "ll" would result in "l")
                                      * # and
                                      yн®нQ # Where the first character of the substring and pair are the same
                                      * # and
                                      yθ®θQ # Where the last character of the substring and pair are the same
                                      # i.e. "po" →
                                      # i.e. "ll" → ["lazsxdcfvgbhnjmkl"]
                                      yª # After filtering, append the current pair to the filtered list
                                      # i.e. → ["po"]
                                      # i.e. ["lazsxdcfvgbhnjmkl"] → ["lazsxdcfvgbhnjmkl","ll"]
                                      н # Get the first item
                                      # ["po"] → "po"
                                      # ["lazsxdcfvgbhnjmkl","ll"] → "lazsxdcfvgbhnjmkl"
                                      ¨ # Remove the last character
                                      # i.e. "po" → "p"
                                      # i.e. "lazsxdcfvgbhnjmkl" → "lazsxdcfvgbhnjmk"
                                      } # Close the map
                                      J # Join everything together
                                      # i.e. ["p","o","lazsxdcfvgbhnjmk"] → "polazsxdcfvgbhnjmk"
                                      Iθ« # And append the last character of the input
                                      # (and output the result implicitly)
                                      # i.e. "polazsxdcfvgbhnjmk" and "poll" → "polazsxdcfvgbhnjmkl"






                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered 2 days ago









                                      Kevin Cruijssen

                                      34.9k554184




                                      34.9k554184






















                                          up vote
                                          2
                                          down vote














                                          Charcoal, 48 bytes



                                          ≔”&⌈″⌊5EWXVNa…-εW¶ζR”η≔⌕η§θ⁰ζFθF⊕﹪⁻⌕ηιζ²⁶«§ηζ≦⊕ζ


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



                                          ≔”&⌈″⌊5EWXVNa…-εW¶ζR”η


                                          Get the string qwertyuioplkmjnhbgvfcdxsza.



                                          ≔⌕η§θ⁰ζ


                                          Find the position of the first character of the word. This index is normally one past the character just reached, but this value fakes out the first iteration of the loop to print the first character of the word.



                                          Fθ


                                          Loop over each character.



                                          F⊕﹪⁻⌕ηιζ²⁶«


                                          Compute how many characters to print to include the next character of the word and loop that many times.



                                          §ηζ≦⊕ζ


                                          Print the next character cyclically indexed and increment the index.






                                          share|improve this answer





















                                          • Have you tried rotating the string “qwertyuioplkmjnhbgvfcdxsza” and seeing if any of the rotations happen to be more compressible? I'm not familiar with charcoal's compression; maybe this isn't possible.
                                            – Vaelus
                                            2 days ago












                                          • @Vaelus I don't know either so I tried all 26 rotations but they all compress to 20 bytes. Of course, those aren't all of the possible walks...
                                            – Neil
                                            2 days ago















                                          up vote
                                          2
                                          down vote














                                          Charcoal, 48 bytes



                                          ≔”&⌈″⌊5EWXVNa…-εW¶ζR”η≔⌕η§θ⁰ζFθF⊕﹪⁻⌕ηιζ²⁶«§ηζ≦⊕ζ


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



                                          ≔”&⌈″⌊5EWXVNa…-εW¶ζR”η


                                          Get the string qwertyuioplkmjnhbgvfcdxsza.



                                          ≔⌕η§θ⁰ζ


                                          Find the position of the first character of the word. This index is normally one past the character just reached, but this value fakes out the first iteration of the loop to print the first character of the word.



                                          Fθ


                                          Loop over each character.



                                          F⊕﹪⁻⌕ηιζ²⁶«


                                          Compute how many characters to print to include the next character of the word and loop that many times.



                                          §ηζ≦⊕ζ


                                          Print the next character cyclically indexed and increment the index.






                                          share|improve this answer





















                                          • Have you tried rotating the string “qwertyuioplkmjnhbgvfcdxsza” and seeing if any of the rotations happen to be more compressible? I'm not familiar with charcoal's compression; maybe this isn't possible.
                                            – Vaelus
                                            2 days ago












                                          • @Vaelus I don't know either so I tried all 26 rotations but they all compress to 20 bytes. Of course, those aren't all of the possible walks...
                                            – Neil
                                            2 days ago













                                          up vote
                                          2
                                          down vote










                                          up vote
                                          2
                                          down vote










                                          Charcoal, 48 bytes



                                          ≔”&⌈″⌊5EWXVNa…-εW¶ζR”η≔⌕η§θ⁰ζFθF⊕﹪⁻⌕ηιζ²⁶«§ηζ≦⊕ζ


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



                                          ≔”&⌈″⌊5EWXVNa…-εW¶ζR”η


                                          Get the string qwertyuioplkmjnhbgvfcdxsza.



                                          ≔⌕η§θ⁰ζ


                                          Find the position of the first character of the word. This index is normally one past the character just reached, but this value fakes out the first iteration of the loop to print the first character of the word.



                                          Fθ


                                          Loop over each character.



                                          F⊕﹪⁻⌕ηιζ²⁶«


                                          Compute how many characters to print to include the next character of the word and loop that many times.



                                          §ηζ≦⊕ζ


                                          Print the next character cyclically indexed and increment the index.






                                          share|improve this answer













                                          Charcoal, 48 bytes



                                          ≔”&⌈″⌊5EWXVNa…-εW¶ζR”η≔⌕η§θ⁰ζFθF⊕﹪⁻⌕ηιζ²⁶«§ηζ≦⊕ζ


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



                                          ≔”&⌈″⌊5EWXVNa…-εW¶ζR”η


                                          Get the string qwertyuioplkmjnhbgvfcdxsza.



                                          ≔⌕η§θ⁰ζ


                                          Find the position of the first character of the word. This index is normally one past the character just reached, but this value fakes out the first iteration of the loop to print the first character of the word.



                                          Fθ


                                          Loop over each character.



                                          F⊕﹪⁻⌕ηιζ²⁶«


                                          Compute how many characters to print to include the next character of the word and loop that many times.



                                          §ηζ≦⊕ζ


                                          Print the next character cyclically indexed and increment the index.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered 2 days ago









                                          Neil

                                          78.6k744175




                                          78.6k744175












                                          • Have you tried rotating the string “qwertyuioplkmjnhbgvfcdxsza” and seeing if any of the rotations happen to be more compressible? I'm not familiar with charcoal's compression; maybe this isn't possible.
                                            – Vaelus
                                            2 days ago












                                          • @Vaelus I don't know either so I tried all 26 rotations but they all compress to 20 bytes. Of course, those aren't all of the possible walks...
                                            – Neil
                                            2 days ago


















                                          • Have you tried rotating the string “qwertyuioplkmjnhbgvfcdxsza” and seeing if any of the rotations happen to be more compressible? I'm not familiar with charcoal's compression; maybe this isn't possible.
                                            – Vaelus
                                            2 days ago












                                          • @Vaelus I don't know either so I tried all 26 rotations but they all compress to 20 bytes. Of course, those aren't all of the possible walks...
                                            – Neil
                                            2 days ago
















                                          Have you tried rotating the string “qwertyuioplkmjnhbgvfcdxsza” and seeing if any of the rotations happen to be more compressible? I'm not familiar with charcoal's compression; maybe this isn't possible.
                                          – Vaelus
                                          2 days ago






                                          Have you tried rotating the string “qwertyuioplkmjnhbgvfcdxsza” and seeing if any of the rotations happen to be more compressible? I'm not familiar with charcoal's compression; maybe this isn't possible.
                                          – Vaelus
                                          2 days ago














                                          @Vaelus I don't know either so I tried all 26 rotations but they all compress to 20 bytes. Of course, those aren't all of the possible walks...
                                          – Neil
                                          2 days ago




                                          @Vaelus I don't know either so I tried all 26 rotations but they all compress to 20 bytes. Of course, those aren't all of the possible walks...
                                          – Neil
                                          2 days ago


















                                          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).






                                          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                          Please pay close attention to the following guidance:


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177096%2fwalk-across-a-keyboard%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

                                          Plaza Victoria

                                          In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

                                          How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...