Flavortext
So...this is awkward. It seems I accidentally turned into a monkey last night after eating one too many banana sundaes. This has made many things inconvenient, especially typing. You see, monkeys only need the following characters: uppercase letters (A-Z
), space, comma (,
), exclamation mark (!
), and question mark (?
). For all other purposes, the Stack Overflow keyboard is enough for copy-pasting a.k.a. monkey see, monkey do. Furthermore, since we are superior to humans and do not have opposable thumbs, we can use our thumbs for more than just the space bar. Finally, monkeys absolutely hate typing consecutive characters with the same finger, so typing combos such as "dee" and "un" on a QWERTY keyboard is very annoying.
Task
That's why I've made a new ergonomic keyboard that looks like this, and your task is to assign its keys.
Left paw Right paw
⎕⎕⎕⎕⎕ ⎕⎕⎕⎕⎕
⎕⎕⎕⎕⎕ ⎕⎕⎕⎕⎕
⎕⎕⎕⎕⎕ ⎕⎕⎕⎕⎕
Every finger is used for the three keys in one column and only those keys (so the left pinky would be used for the first column and the right thumb for the sixth).
You will be given a string representative of what I usually type, and will design a keyboard according to the following requirements:
- It will be in the shape of the blank keyboard above.
- It will contain the characters
ABCDEFGHIJKLMNOPQRSTUVWXYZ ,!?
(note the space) and only those characters. - None of the strings in the input will cause me to type consecutive characters using the same finger.
Here's an example:
Input: 'I LIKE BANANAS! WHERE BANANA?!'
A valid keyboard would be:
I
L
A
N
R
D
F
G
J
M
E
K
!
S
?
Z
O
P
Q
T
B
Y
W
H
C
,
U
V
X
An invalid keyboard would be:
I
E
A
N
R
D
F
G
J
M
L
K
!
S
?
Z
O
P
Q
T
B
W
H
C
,
U
V
X
Y
This violates the third requirement, because to type LI
in I LIKE BANANAS!
, I would have to use my left pinky twice for consecutive characters: once for L
on the middle row and once for I
on the top row. I would also have to use my left ring finger twice while typing KE
.
Rules
- The input will always consist only of the characters
ABCDEFGHIJKLMNOPQRSTUVWXYZ ,!?
, just like the keyboard. - You may assume that a valid keyboard exists for the input.
- You may input and output in any reasonable format.
Test cases
The output of each test case is formatted the same as the examples above, but without <kbd>
and spaces between the two paws' keys. An underscore (_
) is used instead of a space for clarity.
'Input'
Keyboard
'I HAVE A TAIL AND YOU DO NOT! WHY?! I PITY YOU!'
I_HAVETLND
Y?OUWPBCF,
!GJKMQRSXZ
'REJECT MODERNITY, RETURN TO MONKE! EAT BANANA!'
RECOD!BQSX
JNKI,FGAV?
TM_YUHLPWZ