Text may be translated to a written version of TUT language by replacing each letter by the corresponding "TUT word", as given in the following table (adapted from the linked article)*:
a e h hash o o u yu b bub i ay p pup v vuv c kut j jag q kwak w waks d dud k kak r rut x eks e i l lul s sus y yak f fuf m mum t tut z zuz g jug n nun * Exceptions: (1) Upper case letters have corresponding TUT words in upper case. (2) A doubled letter becomes 'skwer' ('SKWER') followed by the TUT word for that letter. - An n-fold letter is treated as a number of doubles, followed by a single if needed. - To be considered a double or n-fold letter, the letters must be in the same case. (3) 'rut' ('RUT') is replaced by 'rud' ('RUD') if immediately followed by 'dud' ('DUD').
Write a program with the following i/o behavior:
Input (from stdin): A binary (0/1) indicator i and an ASCII string s.
- If i = 0 then s may contain any ASCII text.
- If i = 1 then s must be the TUT Language output for some valid input.
Output (to stdout): A binary (0/1) indicator j and an ASCII string t.
- If i = 0 then j = 1 and t is the translation of s to TUT Language.
- If i = 1 then j = 0 and t is the translation of s from TUT Language.
- For any valid input, applying the program to its own output must exactly reproduce the original input; i.e., program (program (i, s)) = (i, s). Input and output must have exactly the same format.
Scoring: The score is the number of characters in the program -- lowest score wins.
(0, 'Look for the birds.') (1, 'LULskwerokak fuforut tuthashi bubayruddudsus.')
(0, '"Mrs. Hogwallop up and R-U-N-N-O-F-T."') (1, '"MUMrutsus. HASHojugwakseskwerlulopup yupup enundud RUT-YU-NUN-NUN-O-FUF-TUT."')
(0, 'QWX WWW Rrrrd deeeeep') (1, 'KWAKWAKSEKS SKWERWAKSWAKS RUTskwerrutruddud dudskweriskweriipup')
(0, 'aa AA aA Aa rd RD rD Rd') (1, 'skwere SKWERE eE Ee ruddud RUDDUD rutDUD RUTdud)
(((Aside about pronunciation: The TUT words for the vowels (
yu) are supposed to represent the usual sounds of (a, e, i, o, u) when reciting the alphabet -- i.e., rhyming with (may, me, my, mow, mew). In the three-or-more-letter TUT words, the symbols (
e) are supposed to sound as in (but, bat, bet) respectively -- these are ASCII replacements for (
ɛ) in the linked article.)))