Concept
Remembering numbers can be difficult. Remembering a word may be easier. In order to memorize big numbers, I created a way to pronounce them in a leetspeak-like way.
Rules
Each digit is first replaced by its corresponding letter:
0 => O
1 => I
2 => R
3 => E
4 => A
5 => S
6 => G
7 => T
8 => B
9 => P
After the replacement, two additional things are done to improved pronunciation:
Between two consonants, a
U
is added.Between two vowels, a
N
is added.
Examples/test cases
512431 => SIRANENI
834677081 => BENAGUTUTOBI
3141592 => ENINANISUPUR
1234567890 => IRENASUGUTUBUPO
6164817 => GIGABIT
What's impossible
- Letters and numbers mixed in the same word
- Two successive consonants or two successive vowels
- Letters that are not in the list above
- Other characters
Rules
The goal of this code-golf is to create a 2-way translator for this concept.
- Your program must first understand by itself if it's letter-to-number or number-to-letter translation.
- It must check for the entry to be properly formed.
- If everything is correct, display the translation.
- Else, display an error message, nothing, return a falsey value or crash the program.
Details
- The input number/string can be entered in whatever format you want (stdin, argument, ...)
- This is code-golf, so shortest answer wins.
- Standard loopholes are forbidden.
GIGATESTER
beGIGATESUTER
? \$\endgroup\$AB23
;AEI
;BB
;Z
;ACE
;giga
;!@#$
;-123
; etc. Also, based on the validation rules, we can convert6164735732 => GIGATESTER
, butGIGATESTER
will result in a false value, because ofST
(two successive consonants rule). The way your challenge is currently set up, the main part of the challenge is the validation, instead of the conversion. I'm fine with that, but the validation should be defined a bit better in that case. \$\endgroup\$