CJam, 83 75 74 바이트
l_1>]z["qwertyuiop asdfghjkl zxcvbnm "[__B>]z+s_W%+_]zsf{\#)}:*"Yes""No"?
온라인으로 사용해보십시오.
설명
일반적인 접근 방식은 모든 인접 키보드 문자 쌍을 포함하는 큰 인접 문자열을 생성 한 다음 모든 인접 입력 문자 쌍이 해당 문자열에 포함되어 있는지 확인하는 것입니다.
매우 간단하고 컴팩트 한 논리를 사용하는 인접 문자열을 작성하는 방법에 매우 만족합니다.
l_1>]z "Read a line of input and create a list of every pair of
adjacent input characters. There will be a trailing element
of just the final character, but that's okay since any single
lowercase letter can be found in the adjacency string.";
["qwertyuiop asdfghjkl zxcvbnm "
"^ Create the in-row forward adjacency string.";
[__B>]z "Create the alternating-row forward adjacency string by
interleaving the in-row string with a substring of itself
starting with the middle row letters:
'q w e r t y u i o p a s d f g h j k l zxcvbnm '
+ ' a s d f g h j k l z x c v b n m '[no interleave here]
-----------------------------------------------------
'qawsedrftgyhujikolp azsxdcfvgbhnjmk l zxcvbnm '";
+s "Append the alternating-row forward adjacency string to the
in-row forward adjacency string.";
_W%+ "Append the reverse of the forward adjacency string (the
backward adjacency string) to the forward adjacency string.";
_]zs "Double every character in the adjacency string so every
character is adjacent to itself.";
f{\#)} "Map each pair of input characters to its 1-indexed location in
the adjacency string (0 if not found).";
:* "Calculate the product of each pair's location in the adjacency
string. This will be nonzero if and only if every pair of
input characters are in fact adjacent.";
"Yes""No"? "If the product is nonzero, produce 'Yes'; otherwise, produce
'No'.";
"Implicitly print the result.";