4
1
John Doe used to be one of the fastest QWERTY keyboard typists in the world, but a recent head injury caused by a stampeding herd of downgoats has critically hampered his ability to type accurately. In a desperate effort to retain his reputation as a typing prodigy, he has tasked us with the creation of a spellchecker - well, sort of. This spellchecker's rigged so that John Doe can worry less about accuracy and more about speed.
Challenge
Here's the keyboard you'll be using. NOTE: non-spacebar keys are separated by 2 spaces, with the unshifted key followed by the shifted key.
`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+
Tab qQ wW eE rR tT yY uU iI oO pP [{ ]} \|
aA sS dD fF gG hH jJ kK lL ;: '" enter
zZ xX cC vV bB nN mM ,< .> /?
[ SPACEBAR ]
Notice how I have arranged the keys to line up properly. This is crucial for this challenge to work.
Write a full program/function that, given 2 strings of equal length containing only characters from the above keyboard, outputs a truthy/falsy value according to the following:
If all characters' keys are at most 1 away (horizontally, vertically, or diagonally) from the characters' keys at the same index in string 2, then output truthily.
Example using
a
: Any characters inaAqQsSzZwWxX
or\t
(tab key) would return truthily.Special cases:
\n
(enter key) would return truthily for any character in[{]}\|'"
or\n
. Spaces (spacebar key) would return truthily for any character inxXcCvVbBnNmM,<
or spaces.
Otherwise, output falsily.
Note: Tabs and newlines will be actual representations instead of their escaped equivalents (\t
and \n
).
This is code-golf; shortest code wins.
Example test cases
String1 String2 Output
---------------------------------
asdf QWeR => true
cat gsl => false
12345 qWeRty => true
John Doe Jonh Deo => false
3"a recent head injury caused by a stampeding herd of downgoats" ಠ_______ಠ – Downgoat – 2016-02-02T04:04:31.163
Well, I mean, he did post some pretty badly-golfed answers... – Mama Fun Roll – 2016-02-02T04:09:27.053
@Downgoat I'll get you for what you did to him. – workoverflow – 2018-03-18T10:55:13.653