Walk Across a Keyboard
up vote
20
down vote
favorite
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:
q
w
e
r
t
y
u
i
o
p
a
s
d
f
g
h
j
k
l
z
x
c
v
b
n
m
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
add a comment |
up vote
20
down vote
favorite
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:
q
w
e
r
t
y
u
i
o
p
a
s
d
f
g
h
j
k
l
z
x
c
v
b
n
m
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
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 likedewqwerty
is a valid path fordy
. 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
add a comment |
up vote
20
down vote
favorite
up vote
20
down vote
favorite
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:
q
w
e
r
t
y
u
i
o
p
a
s
d
f
g
h
j
k
l
z
x
c
v
b
n
m
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
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:
q
w
e
r
t
y
u
i
o
p
a
s
d
f
g
h
j
k
l
z
x
c
v
b
n
m
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
code-golf keyboard
asked Dec 6 at 21:08
Vaelus
292112
292112
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 likedewqwerty
is a valid path fordy
. 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
add a comment |
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 likedewqwerty
is a valid path fordy
. 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
add a comment |
6 Answers
6
active
oldest
votes
up vote
6
down vote
accepted
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
add a comment |
up vote
14
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.
2
How come theimport re
comes after the code, not before?
– BruceWayne
Dec 7 at 20:44
@BruceWayne There.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
Dec 7 at 23:17
@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
Dec 7 at 23:25
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
Dec 7 at 23:27
add a comment |
up vote
7
down vote
Python 2, 274 bytes (optimal solution)
296 300 302 308 315 319 324 327 328 430 432 bytes
-4 bytes thanks to mypetlion
from networkx import*
i=input()
M,z='qwertyuiop asdfghjkl zxcvbnm'.center(55),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]])
for y,x in zip(i,i[1:]):z+=[shortest_path(G,y,x)[1:],list(G[y])[0]+y][x==y]
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
274 bytes: Try it online!
– mypetlion
Dec 11 at 20:17
1
@mypetlion u made an important reduction, u can update the answer :)
– mdahmoune
Dec 11 at 20:56
add a comment |
up vote
4
down vote
JavaScript (ES6), 70 bytes
Same strategy as TFeld.
s=>'qazsxdcfvgbhnjmklpoiuytrew'.repeat(s.length).match(s.join`.*?`)[0]
Try it online!
add a comment |
up vote
3
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"
add a comment |
up vote
3
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.
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
Dec 8 at 0:06
@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
Dec 8 at 1:04
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
6
down vote
accepted
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
add a comment |
up vote
6
down vote
accepted
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
add a comment |
up vote
6
down vote
accepted
up vote
6
down vote
accepted
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
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
edited Dec 7 at 4:48
answered Dec 7 at 1:21
Kamil Drakari
2,931416
2,931416
add a comment |
add a comment |
up vote
14
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.
2
How come theimport re
comes after the code, not before?
– BruceWayne
Dec 7 at 20:44
@BruceWayne There.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
Dec 7 at 23:17
@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
Dec 7 at 23:25
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
Dec 7 at 23:27
add a comment |
up vote
14
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.
2
How come theimport re
comes after the code, not before?
– BruceWayne
Dec 7 at 20:44
@BruceWayne There.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
Dec 7 at 23:17
@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
Dec 7 at 23:25
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
Dec 7 at 23:27
add a comment |
up vote
14
down vote
up vote
14
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.
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.
answered Dec 6 at 21:33
TFeld
14.1k21240
14.1k21240
2
How come theimport re
comes after the code, not before?
– BruceWayne
Dec 7 at 20:44
@BruceWayne There.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
Dec 7 at 23:17
@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
Dec 7 at 23:25
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
Dec 7 at 23:27
add a comment |
2
How come theimport re
comes after the code, not before?
– BruceWayne
Dec 7 at 20:44
@BruceWayne There.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
Dec 7 at 23:17
@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
Dec 7 at 23:25
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
Dec 7 at 23:27
2
2
How come the
import re
comes after the code, not before?– BruceWayne
Dec 7 at 20:44
How come the
import re
comes after the code, not before?– BruceWayne
Dec 7 at 20:44
@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
Dec 7 at 23:17
@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
Dec 7 at 23:17
@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
Dec 7 at 23:25
@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
Dec 7 at 23:25
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
Dec 7 at 23:27
@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
Dec 7 at 23:27
add a comment |
up vote
7
down vote
Python 2, 274 bytes (optimal solution)
296 300 302 308 315 319 324 327 328 430 432 bytes
-4 bytes thanks to mypetlion
from networkx import*
i=input()
M,z='qwertyuiop asdfghjkl zxcvbnm'.center(55),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]])
for y,x in zip(i,i[1:]):z+=[shortest_path(G,y,x)[1:],list(G[y])[0]+y][x==y]
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
274 bytes: Try it online!
– mypetlion
Dec 11 at 20:17
1
@mypetlion u made an important reduction, u can update the answer :)
– mdahmoune
Dec 11 at 20:56
add a comment |
up vote
7
down vote
Python 2, 274 bytes (optimal solution)
296 300 302 308 315 319 324 327 328 430 432 bytes
-4 bytes thanks to mypetlion
from networkx import*
i=input()
M,z='qwertyuiop asdfghjkl zxcvbnm'.center(55),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]])
for y,x in zip(i,i[1:]):z+=[shortest_path(G,y,x)[1:],list(G[y])[0]+y][x==y]
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
274 bytes: Try it online!
– mypetlion
Dec 11 at 20:17
1
@mypetlion u made an important reduction, u can update the answer :)
– mdahmoune
Dec 11 at 20:56
add a comment |
up vote
7
down vote
up vote
7
down vote
Python 2, 274 bytes (optimal solution)
296 300 302 308 315 319 324 327 328 430 432 bytes
-4 bytes thanks to mypetlion
from networkx import*
i=input()
M,z='qwertyuiop asdfghjkl zxcvbnm'.center(55),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]])
for y,x in zip(i,i[1:]):z+=[shortest_path(G,y,x)[1:],list(G[y])[0]+y][x==y]
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
Python 2, 274 bytes (optimal solution)
296 300 302 308 315 319 324 327 328 430 432 bytes
-4 bytes thanks to mypetlion
from networkx import*
i=input()
M,z='qwertyuiop asdfghjkl zxcvbnm'.center(55),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]])
for y,x in zip(i,i[1:]):z+=[shortest_path(G,y,x)[1:],list(G[y])[0]+y][x==y]
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
edited Dec 11 at 23:02
Οurous
6,31811032
6,31811032
answered Dec 7 at 15:35
mdahmoune
1,4501723
1,4501723
274 bytes: Try it online!
– mypetlion
Dec 11 at 20:17
1
@mypetlion u made an important reduction, u can update the answer :)
– mdahmoune
Dec 11 at 20:56
add a comment |
274 bytes: Try it online!
– mypetlion
Dec 11 at 20:17
1
@mypetlion u made an important reduction, u can update the answer :)
– mdahmoune
Dec 11 at 20:56
274 bytes: Try it online!
– mypetlion
Dec 11 at 20:17
274 bytes: Try it online!
– mypetlion
Dec 11 at 20:17
1
1
@mypetlion u made an important reduction, u can update the answer :)
– mdahmoune
Dec 11 at 20:56
@mypetlion u made an important reduction, u can update the answer :)
– mdahmoune
Dec 11 at 20:56
add a comment |
up vote
4
down vote
JavaScript (ES6), 70 bytes
Same strategy as TFeld.
s=>'qazsxdcfvgbhnjmklpoiuytrew'.repeat(s.length).match(s.join`.*?`)[0]
Try it online!
add a comment |
up vote
4
down vote
JavaScript (ES6), 70 bytes
Same strategy as TFeld.
s=>'qazsxdcfvgbhnjmklpoiuytrew'.repeat(s.length).match(s.join`.*?`)[0]
Try it online!
add a comment |
up vote
4
down vote
up vote
4
down vote
JavaScript (ES6), 70 bytes
Same strategy as TFeld.
s=>'qazsxdcfvgbhnjmklpoiuytrew'.repeat(s.length).match(s.join`.*?`)[0]
Try it online!
JavaScript (ES6), 70 bytes
Same strategy as TFeld.
s=>'qazsxdcfvgbhnjmklpoiuytrew'.repeat(s.length).match(s.join`.*?`)[0]
Try it online!
answered Dec 6 at 23:45
Arnauld
71.7k688299
71.7k688299
add a comment |
add a comment |
up vote
3
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"
add a comment |
up vote
3
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"
add a comment |
up vote
3
down vote
up vote
3
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"
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"
answered Dec 7 at 11:06
Kevin Cruijssen
35.5k554186
35.5k554186
add a comment |
add a comment |
up vote
3
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.
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
Dec 8 at 0:06
@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
Dec 8 at 1:04
add a comment |
up vote
3
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.
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
Dec 8 at 0:06
@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
Dec 8 at 1:04
add a comment |
up vote
3
down vote
up vote
3
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.
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.
answered Dec 7 at 13:34
Neil
78.9k744175
78.9k744175
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
Dec 8 at 0:06
@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
Dec 8 at 1:04
add a comment |
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
Dec 8 at 0:06
@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
Dec 8 at 1:04
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
Dec 8 at 0:06
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
Dec 8 at 0:06
@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
Dec 8 at 1:04
@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
Dec 8 at 1:04
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 fordy
. 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