When babies open their mouths, they're not just spewing gibberish. They're actually talking in a highly advanced, adult-proof cipher...
The Baby-talk Cipher
When a baby talks, it could look something like gogooa gagooook aagaaoooy
Each single-space separated section represents a character (so the example above represents 3 characters).
To decipher a section, we must count number of As and Os it contains. However, we only count those which are adjacent to another vowel. For example, the A in 'gag' would not count, but both the A and O in 'gaog' would.
Counting the example above would look like this:
Section | Num Os | Num As
gogooa | 2 | 1
gagooook | 4 | 0
aagaaoooy | 3 | 4
We then use these values to convert the input into plaintext on a Polybius square. This is a 5x5 representation of the English alphabet, omitting 'J' (please note that, in baby-talk, 0-counting rules apply to the table):
0 1 2 3 4
0 A B C D E
1 F G H I K
2 L M N O P
3 Q R S T U
4 V W X Y Z
Using the number of Os as the column, and number of As as the row, we find which character each section represents:
Section | Num Os | Num As | Character
gogooa | 2 | 1 | (2,1) -> H
gagooook | 4 | 0 | (4,0) -> E
aagaaoooy | 3 | 4 | (3,4) -> Y
Which tells us that the baby was just saying "HEY".
Notes:
- If a section representing a character has more than 4 As or Os, ignore the extras, because 4 is the maximum value on the table.
- For this task, Y is not a vowel - only A, E, I, O and U.
The Challenge
Your task is to create a full program which takes one input, a word in baby-speak, and prints it in plaintext.
- Your program must be able to take input in uppercase, lowercase, and a mix of both.
- The input will only contain ASCII alphabet letters (A-Z and a-z), with single spaces to seperate the baby words.
- The output text can be in any case.
- You should the take the input from
STDIN
and print the plaintext onSTDOUT
. If your language does not have these, use the nearest equivalent. - This is code-golf, so the shortest code in bytes wins - but any solution is welcome.
Test Cases
'GLOOG KAKAAOOO ARGOOO OOOOOGUGUU' -> CODE
'oaka pooopaa gaau augu' -> GOLF
'Aoao U oOOAoa oaoAoo aoAoAOa' -> NAPPY
'GUG gAGaA gOougOou' -> ALE
'OOaGOG GoGOOoGoU gAA bLAA GOUGoOUgAIGAI' -> HELLO
'GUG gAGaA gOougOou' -> 'ALE'
Babies drink ale? :D \$\endgroup\$.toUpperCase()
or similar function call, not an actually stimulating challenge \$\endgroup\$gogooa
have 2 o's? And how doesgagooook
have 0 a's? \$\endgroup\$FAG
:P \$\endgroup\$