{{announcement.body}}
{{announcement.title}}

Code Challenge: Decoder Code Golf

DZone 's Guide to

Code Challenge: Decoder Code Golf

Take DZone's challenge to create a program that outputs deciphered text and the cipher used!

· Web Dev Zone ·
Free Resource

Comment (7)

Save
{{ articles[0].views | formatCount}} Views

Last Week's Winners:

I'm actually going to list three winners for last week, the first for being the village idiot and that goes to the guy trying to sell rings and bracelets in the comments and I had a really good laugh at the responses Kamilo Kafalos gave him.

As much as I dislike Ruby it appears that the winner for the shortest goes to Chris Sulivan with his Ruby answer `def f(w, s);i=0;w.each_cons(s.size){|*c|;break i if c==[s];i+=1;};end`

The winner for the most elegant—that has proved very tricky indeed to decide upon—goes to joint winners Ulrich Cech for his Java solution and Alexander Karagulamos for his C solution. (Though it was a little cryptic, I liked Jon Hoffman's swift solution very much as well).

This Week's Challenge

I clearly am not challenging you enough, so here is a completely different kind of problem. Let's hope this one gets those neurons working.

Given that you know a random section of modern English prose—about 200 words—has been enciphered using a simple substitution cipher, write a program that is able to give the most probable character mapping in the least number of characters possible. The approach you use is entirely up to you, but you must document the approach used for clarity.

So, for example, you have a piece of text:

THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG, THE LITTLE DOG LAUGHED TO SEE SUCH FUN AND THE COW JUMPED OVER THE MOON.

You have the cipher:

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

H D N R F O L G A N T C Q Y E U J Z I W S M X B K P

The ciphered text:

WGF JSANT DZEXY OEB NSQUFR EMFZ WGF CHPK REL, WGF CAWWCF REL CHSLGFR WE IFF ISNG OSY HYR WGF NEX NSQUFR EMFZ WGF QEEY.

Definition and Rules:

• You do not know the piece of text I will use

• You do not know the substitution cipher I have used

• The program must output the deciphered text

• The program must output the substitution cipher used

• The program should be as short as possible (least number of characters)

• You may use the language of your choice but the language must be stated and there must be an online interpreter for this language. In the case of obscure languages, if you can supply a link better still.

Next week I will publish the plain text, the substitution cipher used, and the winner.

Hints:

Both the plain text and the ciphered text will contain spaces.

The following sites might give you a few ideas:

https://en.wikipedia.org/wiki/Frequency_analysis

https://en.wikipedia.org/wiki/Most_common_words_in_English

Have fun, and happy decoding...

Topics:
code challenge

Comment (7)

Save
{{ articles[0].views | formatCount}} Views

Opinions expressed by DZone contributors are their own.