Inspiration
The longest words that can be typed with only the left hand on a standard QWERTY keyboard are "sweaterdresses", "tesseradecades", and "aftercataracts" (Source: Wikipedia).
Challenge
Given as input a "keyboard" \$K\$ and a string \$S\$ determine whether \$S\$ can be typed using only the left hand on keyboard \$K\$.
Input
The keyboard \$K\$ will be provided as a list of 3 rows. You may take this input in any reasonable format (eg. a list of 3 strings, a list of 3 lists of characters, etc.), but please do not take the left-hand-side and right-hand-side of the keyboard separately, as that defeats the purpose of the challenge.
You may assume that the input contains only lowercase letters (or only uppercase letters if you wish). Each of the three rows of the keyboard may be of any non-zero size, but each letter from a-z
will appear only once on the keyboard.
Example 1: [qwertyuiop
, asdfghjkl
, zxcvbnm
]
Example 2: [qazwsxplkm
, edcrfv
, tgbyhnuji
]
The string \$S\$ may also be taken as input in any reasonable format.
Output
Output a truthy value if the string \$S\$ can be typed using the left hand on the keyboard \$K\$ and a falsey value otherwise.
For the purposes of this challenge: A word can be typed with the left hand if it is made up solely of letters appearing in the first half of each row of the keyboard. If a row contains an odd number of letters, the middle letter is also included in the first half.
Using the row asdfghjkl
as an example, the word gafs
can be typed with the left hand.
Scoring
This is code-golf. Make your code as short as possible.
Test Cases
These are formatted as \$K\$, \$S\$ ->
(expected output)
[qwertyuiop, asdfghjkl, zxcvbnm], qazg -> true
[qwertyuiop, asdfghjkl, zxcvbnm], qpazg -> false
[p, asdfghjklqwertyuio, zxcvbnm], sxzklkl -> true
[p, asdfghjklqwertyuio, zxcvbnm], b -> false
[qazwsxplkm, edocrfv, tgbyhnuji], bad -> true
[qazwsxplkm, edocrfv, tgbyhnuji], tex -> false
[thequick, brownfx, jmpsvlazydg], brow -> true
[thequick, brownfx, jmpsvlazydg], fox -> false
qazwsxplkm, edcrfv, tgbyhnuji
doesn't contains lettero
? So will there be a testcase, like,[qazwsxplkm, edcrfv, tgbyhnuji], zoo
? \$\endgroup\$