# Lojic Technologies

## Telogis Puzzle

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.

September 19, 2007 at 11:23 am

Posted in programming

Tagged with , ,

### 6 Responses

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
``` 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. Ed

September 22, 2007 at 6:25 am

4. 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. September 25, 2007 at 1:24 pm

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

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