The Friday Fragment

Published on 21 May 2010
This post thumbnail

It's Friday, and time again for a new Fragment: my weekly programming-related puzzle.

This Week's Fragment

This one's for Luke, who enjoyed our last cryptogram. Solve the following programming-related cipher:

Baae jaanklb xpnrv xksr. Ki gaq pwr sper xa cpkx, kx kv xa vrwhr gaq urxxrw, ple xa ftrpvr gaq.

This uses simple substitution, so just plug at it with pencil and paper, building up the substitution table as you go. For extra credit, tell us the source of this quote. If you're ambitious, try coding a cracker, or at least a cryptogram generator.

If you want to “play along”, post the solution as a comment or send it via email. To avoid “spoilers”, simply don’t expand comments for this post.

Last Week's Fragment - Solution

Last week's challenge was to write code to solve a recent Car Talk Puzzler; that is:

Write code to find two (two-digit) temperatures where the (rounded) Celsius and Fahrenheit readings have the same digits, only reversed.

The conversion to Fahrenheit is 1.8 (or 9/5) times Celsius plus 32. If you round the result, you find that 16 Celsius is 61 Fahrenheit and 28 Celsius is 82 Fahrenheit: handy numbers to remember when you want a quick approximate conversion from the current temp.

I invited folks to code it in multiple languages to compare, and even try esoteric languages. Joel coded it in Python and demonstrated the strength of its range function when used with iterators. He also showed off reversing a string via a "slice with inverse stride", which sounds like my golf technique. Wayne's Smalltalk example demonstrated how it can elegantly iterate over a range using blocks/closures, a technique and style so nice that Ruby ripped it off. Spencer coded it in Shakespeare but, alas, had problems with the interpreter (it was not to be). I tried LOLCODE , and likewise had interpreter problems, so I did a quick PHP implementation also. Gee, I wonder why there aren’t any production-ready LOLCODE or Shakespeare compilers?

Thanks to all for posting; code fragments like these provide good opportunities to compare language features and learn new approaches. For all these implementations, see the comments in last week's post.