4
\$\begingroup\$

This question already has an answer here:

You are in fact writing an interpreter for the language "Wrong keyboard position". You can pretend that you are not doing this and just follow the instructions below.


I typr re;atively accuratrly, but so,etimes I made a whole nlock of text illegible by shifting a key right. So I need a program that corrects my text back to its original meaning.

Rules

  • You have to left shift on a standard English QWERTY keyboard.
  • Whitespace do not count for the procedure before left-shifting and are kept as-is in a standard left-shifting procedure. If the key is the leftmost letter/symbol on a keyboard(i.e. The ~key, Q key, A key, Z key.), the key is kept as-is. If you reach a control character while left-shifting (Caps lock and Shift), their effects will not be triggered and the character before left-shifting is kept.
  • This is a contest; the shortest answer wins.
  • Both the input and the output shall be given via our default methods.

Representation of a subset of the QWERTY keyboard that you will need

The two lines connected are possible values of the key: shifted/unshifted.

~!@#$%^&*()_+
`1234567890-=

QWERTYUIOP{}|
qwertyuiop[]\

ASDFGHJKL:"
asdfghjkl;'

ZXCVBNM<>?
zxcvbnm,./

(Space)
(Space)

Input

The input will always be a non-empty string conforming the rules above.

Output

The output will be the input string corrected to the originally intended meaning.

Examples:

Yjod ,sfr yjr, imjsppu/ -> This made them unhaooy.
vpfr hp;g -> code golf
\$\endgroup\$

marked as duplicate by Shaggy code-golf Sep 10 at 11:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    \$\begingroup\$ Test case fixed. \$\endgroup\$ – A _ Sep 10 at 11:19
  • \$\begingroup\$ I ported my solution with almost no change, so I'm gonna agree with the duplicate vote. \$\endgroup\$ – Grimy Sep 10 at 12:59
2
\$\begingroup\$

05AB1E, 59 bytes

-1 byte thanks to Kevin Cruijssen

žVDu«1ú`žhÀ“~!@#$%^&*()_+ `ÿ-=ÿ<>?ÿ:"ÿ{}|ÿ,./ÿ;'ÿ[]\“#vy¦y‡

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ -1 using žhÀ instead of 9LJ, so the 0 inside the string can be removed (same applies to your other answer) \$\endgroup\$ – Kevin Cruijssen Sep 11 at 6:19
  • \$\begingroup\$ @KevinCruijssen updated both, thanks! \$\endgroup\$ – Grimy Sep 11 at 10:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.