This question asks for a T9 dictionary matching functionality which is a very interesting problem. But T9 has another way of typing and that is typing character-by-character. You would NOT need a dictionary to implement this keyboard.
Here is key-map of a T9 keyboard if you forgot:
+-------+-------+-------+
| 1 | 2 | 3 |
| .?! | ABC | DEF |
+-------+-------+-------+
| 4 | 5 | 6 |
| GHI | JKL | MNO |
+-------+-------+-------+
| 7 | 8 | 9 |
| PQRS | TUV | WXYZ |
+-------+-------+-------+
| * | 0 | # |
| ← | SPACE | → |
+-------+-------+-------+
How T9 works
To type a character with T9, you need to press number key representing that character n
times. n
is order of that character written on that key. Numbers are the last character you can type for each key. For example, to type B
I press 2
two times, or to type 5
I press 5
four times. To finish typing this character I press #
. *
is simply backspace. In our version of keyboard there is no capitalization.
Input and output examples:
8#99999#055#33#999#22#666#2#777#3# → T9 KEYBOARD
Explanation:
8
selectsT
and#
moves to next character99999
select last character of9
key which is9
and#
moves to next charachter0
inserts a space33
selects second character of3
key which isK
and#
moves to next character- And so on...
Rules
Your function or program should accept a string representing T9 keypresses. Output is the resulting text from those keypresses, as outlined above.
This is basic code golf, so the winner is shortest in bytes, and standard rules/loopholes apply.
T9 KEYBOARD
is completely wrong. That one readsT9 JEYBARD
\$\endgroup\$#
if consecutive buttons are different anyway. that being said: without that bonus what should happen if#
is omitted? \$\endgroup\$