This challenge is about converting from morse code to english. There are actually two different challenges and two different text files encoded. You can enter the lesser challenge or the greater challenge or indeed both!
Letter Morse
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 --..
The Lesser Challenge
Take a text file of bits (chars 0 and 1). This represents International Morse Code encoded into binary with a 1 representing a dot, a 0 representing the pause between dots and dashes, and a dash is 111. The space between two letters in a word is 000 and between two words is 0000000. So the letter A which is dot dash is 10111. The word DAVID in Morse is
D A V I D
-.. .- ...- .. -..
and encoded in binary (with gaps shown between letters and words) is
D A V I D
1110101 000 10111 000 101010111 000 101 000 1110101 0000000
- Download lesser.zip
So the lesser challenge you just have to decode a text file (just 1 and 0 chars, no line breaks) into English as quickly as possible. There won't be any numbers, or punctuation just the letters A-Z in the output.
The output should be lesstext.txt a text file containing the text decoded followed by a line saying "Average time to decode lesser = 0.006 seconds".
The Greater Challenge
This again uses a file of Morse Code text encoded in binary chars but this time it's lacking the 000 between letters and 0000000 between words. The 0 between dots and dashes still exists (otherwise it would be all 1s!) Your program will still have to make sense of it but to help you, here is the order of letters in English by popularity: ETAONRISHDLFCMUGYPWBVKXJQZ from Most popular letters in English and the text is made up from just the words from this page : 2000 most popular words It has the most popular 2000 words by frequency out of 9,379,000.
This isn't a speed contest, but your program must take no longer than 15 seconds to run. Winners are those who get the exact (approx 250 words) phrase correct (or near it).
- Download greater.zip
- Download 2000words.zip (Zip File)
Timing Code
Please time from after reading the input.txt to doing the output. As this is likely to be very fast, please add code to loop multiple times processing the columns so that the total elapsed time is 1-5 seconds. If for instance it took 0.001 seconds to process the columns once once then a loop of 1000 times should take just about a second to run.
This code below will do high speed timing for Windows (first three) and the fourth one for Linux.
Winning Criteria
This is a pure speed contest. Whoever's code can follow the ten lines to the bottom the fastest wins.
Final Results
Updated Jan 3rd. There were seven entries for the lesser contest, one for the greater from Tavis Bohne (source is in his lined zip file below), solved in 1675 micro secs but it got it partially right!
All lesser entries had fast times, even the solitary C# entry (the rest were in C++, no C!) was in the same order of magnitude as the four faster C++ entries. Congratulations went first to Trifon Triantafillidis but was subsequently changed to Tavis Bohne whose code I had received in November and missed when I first marked this challenge and Tavis's code just pipped Trifon's.
Thank you to all seven entrants. Originally five, I'd missed two, now added.
- Tavis BohneC++ 0.00001787523318 (USA,)
- Trifon TriantafillidisC++ 0.0000195917 (Greece,52)
- Fritz StockerC++ 0.000025249 (Austria,)
- Sipke MellemaC++ 0.000041 (The Netherlands,22)
- Jeremiah HornickC# 0.0000691 (Canada,30)
- Quentin GrosperrinC++ 0.000440483 (France,20)
- Jonathan Lim C++ 0.0150123 (USA,)
Rules
This is for glory only. About.com does not permit prizes to be given.Please submit your source code and the output file to the cplus.guide@about.com?subject=Programming Contest 53 email address with the subject line Programming Contest 53.
It must compile with Open Watcom, Microsoft Visual C++ 2008/2010 Express Edition/Microsoft Visual Studio 2008/2010, CC386 or Borland Turbo C++ Explorer, Microsoft Visual C# 2008/2010 Express Edition or GCC/G++. If it doesn't compile, it can't be run so is automatically disqualified.
Please include your name, age (optional), blog/website url (optional) and country. Your email address will not be kept, used or displayed except to acknowledge your challenge entry. You can submit as many entries as you like before the deadline which is December 31 2011.
The top ten entries in each challenge will be listed, judged on speed (lesser Challenge) and accuracy and speed Greater Challenge). You can enter both. A condition of entry is that you allow your source code to be published on this website, with full credits to you as the author.
- An index of Every Past Programming Contest on this site

