Given the following input:
- An integer
nwheren > 0. - A string
swheresis 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
nbased on its original position + n.- E.G.
s="AB"andn=2:Awould becomeDandBwould becomeM.
- E.G.
- If
keyboard_row[position + n] > keyboard_row.length, wrap back to the start.- E.G.
s="0P"andn=2:0would become2andPwould 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.