The Morse Code Problem
You have intercepted a series of
transmissions on an ancient and unused radio band. It has been determined
that the messages are in some form of Morse code. Your job is to program
your computer to interpret the header of these messages, and then
code and transmit a message.
Input:
The input is a table consisting of two columns: A character in the
first column followed by a space followed by its Morse code representation
as a series of `-' and `.' in the second column. This table is terminated
by a `@' in column 1. The code table is followed by an integer on a line
by itself indicating the maximum
transmition speed in words-per-minute (wpm).
This is followed by the message to be transmitted on one line.
For the purpose of
transmission, end-of-line characters are not to be sent.
Output:
The output is a copy of the message to be sent, one character per
line, where each character
is followed by a listing of how the transmitter will send the character.
The listing is
a sequence of integers: the number of milliseconds
the transmitter will be on and the number of milliseconds the transmitter
will be off to result in the desired speed. Each number
of milliseconds is preceeded
by white space (space or tab) and followed by
white space. Sound times will be followed by a single
character `S' and no sound times will be followed by a single character
`N'. The first number for each character is always a sound time
(transmitter on.)
The required inter-character spacing will be the last entry in
a line. Each line will be terminated by a new-line character.
In determining the speed of transmission of messages in Morse code, the
controlling element is the dot `.'. The dash, `-', is three dots in
length. A word is an average five characters plus a trailing inter-word
space. A character is an average tweleve dots (which includes pauses
between sounds), plus a trailing inter-character space. Inter-character
spaces are one dash long, and inter-word spaces are three dashes long.
Sample:
Input: Output:
A .- A 142 S 142 N 426 S 426 N
B -... 1278 N
... b 426 S 142 N 142 S 142 N 142 S 142 N 142 S 426 N
D -.. a 142 S 142 N 426 S 426 N
... d 426 S 142 N 142 S 142 N 142 S 426 N
O --- 1278 N
... b 426 S 142 N 142 S 142 N 142 S 142 N 142 S 426 N
Y -.-- o 426 S 142 N 426 S 142 N 426 S 426 N
... y 426 S 142 N 142 S 142 N 426 S 142 N 426 S 426 N
@
5
A bad boy
Submit
submit149 morse ...