Morse code P75697


Statement
 

pdf   zip

html

[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 ℓ with ℓ 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
    Event
    Quart Concurs de Programació de la UPC - Semifinal
    Date
    2006-09-20