TIMORSE - Timing Morse
The International Morse Code specifies that the duration of a dash is three times that of a dot; the duration of the interval between the dots and dashes in a single character is the same as the duration of a dot; the duration of the interval between characters in a word is three times the duration of a dot; and the duration of the interval between words is seven times the duration of a dot.
The Morse Code length of a message is the duration of the message as transmitted in Morse code, expressed as a multiple of the duration of a dot.
For example, the Morse Code length of the message "hi" (···· ··) is 7 + 3 + 3 = 13.
The Morse Code length of the message "joe" (·––– ––– ·) is 13 + 3 + 11 + 3 + 1 = 31, and the Morse Code length of the message "hi joe" is 13 + 7 + 31 = 51.
Write a program to calculate the Morse Code length of messages.
For ease of reference, the Morse code you will need (the alphabet) is:
a | ·– | j | ·––– | s | ··· | ||
b | –··· | k | –·– | t | – | ||
c | –·–· | l | ·–·· | u | ··– | ||
d | –·· | m | –– | v | ···– | ||
e | · | n | –· | w | ·–– | ||
f | ··–· | o | ––– | x | –··– | ||
g | ––· | p | ·––· | y | –·–– | ||
h | ···· | q | ––·– | z | ––·· | ||
i | ·· | r | ·–· |
Input
The input to the program should consist of a positive integer, n, on one line, followed by n messages, each on a line of its own. Each message can consist of the letters "a" to "z" plus the space character (any other characters can be ignored).
Output
The output should consist of the n messages each followed by ": length = L", where L is the Morse Code length of the message.
Example
Input: 2 hi joe sos Output: hi joe: length = 51 sos: length = 27
Added by: | handee |
Date: | 2021-06-18 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |