Morse code P75697


Statement
 

pdf   zip

ifnextchar ( ifnextchar (offsettrue(0pt,0pt) offsetfalse ifnextchar [(0pt,0pt)(0pt,0pt) ifnextchar [(0pt,0pt)(0pt,0pt)[l](0pt,0pt)(0pt,0pt)[l][] [r]

A .-
B -...
C -.-.
D -..
E .
F ..-.
G –.
H ....
I ..
J .—
K -.-
L .-..
M
N -.
O
P .–.
Q –.-
R .-.
S ...
T -
U ..-
V ...-
W .–
X -..-
Y -.–
Z –..

Morse code is an old method for transmitting text messages, using only dots (‘.’) and dashes (‘-’). The table to the right shows the corresponce between each letter and its code.

Note that Morse code is not prefix-free; therefore, something must be done to distinguish the start of every letter. In this problem, we prefix every code of length \ell with \ell dots, followed by one dash. For instance, the letter ‘T’ is codified “.--”, the letter ‘E’ is codified “.-.”, and the letter ‘A’ is codified “..-.-”. Hence, the codification of “TEA” is “.--.-...-.-”. We also add the ‘empty codification’ “-” to denote a space.

Your task is simple: decode every given line of Morse code.

Input

Input consists of several lines of Morse code.

Output

Print every line once decoded.

Public test cases
  • Input

    ..-.-....--.......--.-....--...-.....-..-....---.....-......-..
    ....-.---...--.-....-.-....---..--....----....-.--.....---.-...-.-.
    ...-....--...-..-....-...-...-.--....--..-....--.--....---..
    ....-......-..-...-.--...----...-.-.....-.-.....--..
    

    Output

    ABCDEFGHI
    JKLMNOPQR
    STUVWXYZ
    HI WORLD
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++ Haskell