Morse code represents characters as variable length sequences of dots and dashes. In practice, characters in a
message are delimited by short pauses. The following table shows the Morse code sequences:
A .- H .... O --- V ...-
B -... I .. P .--. W .--
C -.-. J .--- Q --.- X -..-
D -.. K -.- R .-. Y -.--
E . L .-.. S ... Z --..
F ..-. M -- T -
G --. N -. U ..-
underscore ..-- period ---.
comma .-.- question mark ----
This problem requires that you implement Ohaver’s encoding algorithm. The input will consist of several messages
encoded with Ohaver’s algorithm. The first line of the input is an integer n that specifies the number of test cases.
The following n lines contain one message per line. Each message will use only the twenty-six capital letters,
underscores, commas, periods, and question marks. Messages will not exceed 100 characters in length.
For each message in the input, output the line number starting in column one, a colon, a space, and then the decoded
message. The output format must be adhered to precisely.
5 AKADTOF_IBOETATUK_IJN PUEL QEWOISE.EIVCAEFNRXTBELYTGD. ?EJHUT.TSMYGW?EJHOT DSU.XFNCJEVE.OE_UJDXNO_YHU?VIDWDHPDJIKXZT?E
1: ACM_GREATER_NY_REGION 2: PERL 3: QUOTH_THE_RAVEN,_NEVERMORE. 4: TO_BE_OR_NOT_TO_BE? 5: THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG
As presented, this encryption scheme is only trivially secure. In fact it offers no security at all if the algorithm is
known to the attacker. The key is the string of numbers needed to decide where the pauses should be inserted to
recover the message, but with the method shown here, this information is encoded in and easily recovered from the
encrypted data. Even should some other method be chosen to scramble the length information in the encoding,
secrecy of the algorithm is the real key in this technique. Modifications of Ohaver’s technique do exist in which the
security is not based on the secrecy of the algorithm.
Migrated from old NTUJ.
Greater New York 2001
No. | Testdata Range | Score |
---|