15
Given a String and an Array as input, your task is to output the text the input String will print when typed on a typical Mobile Keypad. In a Mobile Keypad, a letter is typed by pressing a button n times, where n is the position of where the letter is at on the button's label. So, 22
should output b
.
Rules
The Helper Array will contain the Character Map (
[" ",".,!","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"]
). This will be given to save you some bytes.The
#
symbol will toggle case. Initial Case will be lower. So2#3
should outputaD
.The
0
will add a space. So,202
should outputa a
.There will be a space (
) in the input String to start a new letter that is on the same numeric button. For Example to type
aa
, the input String will be2 2
.It is guranteed that the input String will always be a valid KeyPad Code.
Input
You can take input in whatever way your language supports.
Output
You can output the result in any way you want. Function return
is also allowed.
Test Cases
#4440555#666888330#999#66688111 -> "I Love You!"
#6#33777 7779990#222#4477744477778627777111 -> "Merry Christmas!"
#44#27 79990#66#3390#999#332777111 -> "Happy New Year!"
This is code-golf, so the shortest code in bytes wins!
5Closely related – Mego – 2016-12-24T03:38:30.583
4I think the capitalization on
year
in the last test case is wrong. – Maltysen – 2016-12-24T17:33:24.8201Do we have to consider looping? Like, 2222->invalid or 2222->b? – Kuilin Li – 2016-12-24T18:26:15.507
@Maltysen Yes, you are right. I've edited the question. Thanks for pointing it out. :) – Arjun – 2016-12-24T23:13:24.687
Out of interest, do
##
or double space need to be handled? – Neil – 2017-01-08T17:07:48.047