I came across a web site that required job candidates to solve a puzzle to be able to access a job application page. I’m a sucker for puzzles. The original puzzle is at the following site:
But in case, they take it down at some point, here is the plain text version nicely formatted:
z = 4254145 * 0x18712495;
b = (z & 1) << 4;
a = b--;
o = [];
c = a - b;
x = b - a;
while (z) {
x = a & x ? a & b : c + x;
{
o[z & b^x] = (x + 6 * a + b / 5 - c).chr;
z = z / a / a;
} if (!(z / a & b^x))
}
To apply go to "http://www.telogis.co.nz/" + o + ".html"
I don't think this will parse correctly in any language, but I decided to solve the puzzle using Ruby since it wasn't that far from it and Ruby is my main programming language currently. I had a couple false starts due to a subtlety in Ruby compared to other languages.
I'll come back in a while and post the Ruby solution, but I don't want to post a spoiler too soon.
Tags: programming, puzzle, ruby
-
Ok, as promised, here’s the Ruby solution to get the name of the web page. Ruby doesn’t have a post-decrement operator, so
a=b--was translated toa = b; b -= 1. Also, Ruby has a somewhat different definition of truth, so expressions of the form (x) had to be translated to (x != 0) in cases where non-zero was supposed to be true.require 'pp' z = 4254145 * 0x18712495 b = (z & 1) < < 4 a = b b -= 1 o = [] c = a - b x = b - a while z != 0 x = (a & x) != 0 ? a & b : c + x if (z / a & b^x) == 0 o[z & b^x] = (x + 6 * a + b / 5 - c).chr z = z / a / a end pp o end pp o -
@Ralph hmm… I hadn’t thought about the problem of publishing a solution too soon. If you check back here, let me know what you think would be an appropriate waiting period before posting a solution. Although, I’m sure you can find out rather quickly if a candidate is the type to simply look up a solution instead of solving it themselves.

6 comments
Comments feed for this article
Trackback link: http://lojic.com/blog/2007/09/19/telogis-puzzle/trackback/