Lojic Technologies

Telogis Puzzle

with 6 comments

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:

http://www.telogis.co.nz/

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/&#8221; + 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.

Written by Brian Adkins

September 19, 2007 at 11:23 am

Posted in programming

Tagged with , ,

6 Responses

Subscribe to comments with RSS.

  1. 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 to a = 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
    

    Brian Adkins

    September 20, 2007 at 12:40 pm

  2. Here is another set of programming puzzles that you have to solve in order to get your foot in the door to this company (ITA):

    Ed

    September 22, 2007 at 6:24 am

  3. Thanks for the link Ed. I’ve copied a bunch of puzzles from that site. I’ll post them here periodically. Something tells me that the slowness of Ruby might be a hindrance for some of them; I may have to switch to Lisp.

    Brian Adkins

    September 25, 2007 at 1:24 pm

  4. It was written in ruby originally, but was tweaked not to run in *any* language. I will be constructing another one soon – the answer to this one is everywhere now.

    Ralph Mason

    December 12, 2007 at 2:42 pm

  5. @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.

    Brian Adkins

    December 13, 2007 at 10:32 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: