10
1
I am a robot. I bought this keyboard because of its easy rectangular layout:
~` !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 <, >. ?/
[========= space =========]
To print human text, I need to convert it to commands that my manipulators can interpret. My left manipulator hovers over the Shift key. My right manipulator, at the beginning, hovers over the ~ key. The commands that my manipulators understand are:
S : press the shift key
s : release the shift key
L : move the right manipulator left by 1
R : move the right manipulator right by 1
U : move the right manipulator up by 1
D : move the right manipulator down by 1
P : press the key under the right manipulator
p : release the key by the right manipulator
Write code to convert any ASCII message to a list of commands. The input can contain any number of the 95 printable ASCII characters; possibly also TAB and newline characters. The output should be the list of the commands to the manipulators.
So, for example, to type Hello World!
, the commands are
SRRRRRRDDPp
sLLLUPp
RRRRRRDPp
Pp
UPp
LLLLDDDPp
SLLLUUUPp
sRRRRRRRPp
LLLLLPp
RRRRRDPp
LLLLLLPp
SLLUUPp
I reset the manipulators to initial state before printing each message.
There are some mechanical hazards that should be avoided by proper programming:
- No moving (
LRUD
) allowed when printing (P
) is engaged - No jamming of manipulators: when a manipulator is engaged (
S
orP
), the next command for this manipulator should be disengaging (s
orp
), and vice-versa No unnecessary shifting: between each two shift (
s
,S
) commands, there should be aP
commandSo, to print
~~
, commandsSPpPp
are valid, whileSPpsSPp
are notNo moving out of bounds: no movement command should try to move the right manipulator more than 13 spaces to the right or 4 to the bottom of the initial position (or any spot to the top or left)
Additional notes:
- Pressing a disabled key (command sequence like
DDPp
) results in no keys pressed and is allowed. - Pressing Shift+Tab has no effect, but Shift+Space and Shift+Enter have the same effect as without Shift.
- Pressing on any spot on the space bar and the Enter key has the same effect.
- Whitespace keys in output have no meaning, but can be used to format it in a beautiful way.
Is speed a problem? Could we return the manipulators to their home position between each character (so long as it doesn't include unnecessary shifting, of course)? – Engineer Toast – 2018-05-21T18:05:26.837
No problem. Maybe it could be more interesting without extra movement, but I don't like requiring the best possible output. – anatolyg – 2018-05-21T18:10:27.583
1Related one, related two. – AdmBorkBork – 2018-05-21T18:11:27.010
2You haven't actually defined the task... What character can input contain? What is the actual task (I'm going to guess it's the obvious based on the title, but you should specify nonetheless) – HyperNeutrino – 2018-05-21T18:19:47.160
It seems a person typing on a On Screen Keyboard of a Smart TV using its remote control! I feel I do the same when it is me! Was it your inspiration? – sergiol – 2018-05-21T23:11:49.823
Actually, my inspiration was trying to type while all my fingers except two are smeared with mud. But a Smart TV seems more mainstream! – anatolyg – 2018-05-21T23:33:30.540
Related with a simpler output but more strict constraints. – Arnauld – 2018-05-22T00:18:08.590
3Why bother with
Pp
? As far as I can see those are always a single action and neitherP
orp
can appear on its own. – orlp – 2018-05-22T05:31:24.960Pp and Ss look more robotic. I imagine a simple controller inserting delays between commands and connecting commands to electrical motors after simple parsing. – anatolyg – 2018-05-22T07:40:27.757