Given the following input:
- An integer
n
wheren > 0
. - A string
s
wheres
is not empty ands~=[0-9A-Z]+
(alpha-numeric capitals only).
Using a standard, simplified QWERTY keyboard (as shown below):
1234567890
QWERTYUIOP
ASDFGHJKL
ZXCVBNM
Perform the following operation:
- Find the original row that each character is in on the keyboard.
- Replace the letter with the correct shifted equivalent for
n
based on its original position + n.- E.G.
s="AB"
andn=2
:A
would becomeD
andB
would becomeM
.
- E.G.
- If
keyboard_row[position + n] > keyboard_row.length
, wrap back to the start.- E.G.
s="0P"
andn=2
:0
would become2
andP
would becomeW
.
- E.G.
Examples:
f("0PLM",1) = 1QAZ
f("ZXCVB",2) = CVBNM
f("HELLO",3) = LYDDW
f("0PLM",11) = 1QSV
f("0PLM",2130) = 0PHX
Rules
- This is code-golf, lowest byte-count wins.
This is slightly more difficult than it seems at first glance.