The keitai input method is a method for writing Japanese kana on a 12-key phone keypad. Similar to Western keypads, each kana is assigned to a key; when the key is pressed multiple times, it cycles between all kana assigned to that key.
You will be using the following key-kana assignments, with this order of kana (based on this layout):
Key | Kana |
---|---|
1 | あいうえお |
2 | かきくけこ |
3 | さしすせそ |
4 | たちつてと |
5 | なにぬねの |
6 | はひふへほ |
7 | まみむめも |
8 | やゆよ |
9 | らりるれろ |
0 | わをん |
* | ゛゜小 |
Dakuten, Handakuten, and Small Kana
The *
character (or some other non-digit character of your choice) will apply a dakuten (゛
) or handakuten (゜
), or make small (小
) the kana before it. If a form can't be applied to the kana before it, it is skipped in the cycle.
Kana with dakuten, handakuten, and small forms are in the table below.
Key | Kana | Dakuten | Handakuten | Small |
---|---|---|---|---|
1 | あいうえお | ぁぃぅぇぉ | ||
2 | かきくけこ | がぎぐげご | ||
3 | さしすせそ | ざじずぜぞ | ||
4 | たちつてと | だぢづでど | っ | |
6 | はひふへほ | ばびぶべぼ | ぱぴぷぺぽ | |
8 | やゆよ | ゃゅょ |
Note: つ
is the only t-series kana to have a small form. Input 4**
gives た
because た
cannot be shrunk; but the input 444**
gives small っ
.
Input
A list of strings, with each string containing a series of the same digit.
Output
The hiragana represented by the input.
Test Cases
['2','5'] => 'かな'
['222222','555555'] => 'かな'
['1','99','2','*','44444','111'] => 'ありがとう'
['4','*','2','*','22222','44444','0','999'] => 'だがことわる'
['11111','7','1111','00','33','000','4444', '***','999'] => 'おまえをしんでる'
['2','2','99','7','333'] => 'かかります'
['1','****'] => 'あ'
['4','**'] => 'た'
['444','**'] => 'っ'
['555','***********************'] => 'ぬ'
['22','*','88','*','111','55','88','*','111'] => 'ぎゅうにゅう'
['8','444','4'] => 'やつた'
['8','444','*','4'] => 'やづた'
['8','444','**','4'] => 'やった'
['6'] => 'は'
['6','*'] => 'ば'
['6','**'] => 'ぱ'
['6','***'] => 'は'
Other Rules
- Input can be any reasonable method (list of strings, list of integers, a big string with delimiters, list of run-length-encoded strings, etc.)
- Output can be any reasonable method (printing to STDOUT, returning a string, etc.)
- This is code-golf, so shortest code wins!
*
's in the same string? (e.g.['9','444*','4']
instead of['9','444','*','4']
) \$\endgroup\$*
s in the same string is allowed \$\endgroup\$8
) \$\endgroup\$