Code Puzzle

Cerebral distractions of every kind, mostly but not exclusively Countdown-related.

Moderator: Michael Wallace

Post Reply
User avatar
JimBentley
Fanatic
Posts: 2820
Joined: Fri Jan 11, 2008 6:39 pm
Contact:

Code Puzzle

Post by JimBentley »

Here is a sort of code-breaking puzzle. It might be unsolvable (I'm not really sure if it contains enough information to be solved without an improbable piece of lateral thinking) but I might be wrong. Anyway, I thought I'd put it out there in case anybody would like to have a go.

The following image represents a section of text:

Image

What does it say, and who wrote it?
Gavin Chipper
Post-apocalypse
Posts: 13214
Joined: Mon Jan 21, 2008 10:37 pm

Re: Code Puzzle

Post by Gavin Chipper »

If you've got a "smartphone", just scan it for the answer.
User avatar
Phil Reynolds
Postmaster General
Posts: 3329
Joined: Fri Oct 31, 2008 3:43 pm
Location: Leamington Spa, UK

Re: Code Puzzle

Post by Phil Reynolds »

Gavin Chipper wrote:If you've got a "smartphone", just scan it for the answer.
Have you tried? I too assumed at first it was a QR code, but my iPad doesn't recognise it if it is, nor as a 2D data matrix.
Last edited by Phil Reynolds on Sat Jan 14, 2012 5:36 pm, edited 1 time in total.
User avatar
Graeme Cole
Series 65 Champion
Posts: 2025
Joined: Tue Jul 06, 2010 9:59 pm

Re: Code Puzzle

Post by Graeme Cole »

No, it's not a QR code. QR codes have those concentric squares in three of the corners. Doesn't look like any two-dimensional barcode shown here, either.
Gavin Chipper
Post-apocalypse
Posts: 13214
Joined: Mon Jan 21, 2008 10:37 pm

Re: Code Puzzle

Post by Gavin Chipper »

Phil Reynolds wrote:
Gavin Chipper wrote:If you've got a "smartphone", just scan it for the answer.
Have you tried? I too assumed at first it was a QR code, but my iPad doesn't recognise it if it is, nor as a 2D data matrix.
I'm not up-to-date enough to have one.
Matt Bayfield
Devotee
Posts: 539
Joined: Thu May 14, 2009 8:39 am
Location: Seated at a computer

Re: Code Puzzle

Post by Matt Bayfield »

I noted that the image is a 36 x 36 grid, and if I replaced the black squares with 1, and white with 0, I ended up with 36 lines of binary (seems more logical than setting black = 0, white =1, given the large areas of white space). I then tried breaking down each line into groups of n bits (ideally where n is a factor of 36, for neatness, but this doesn't necessarily have to be the case, if you allow run=on to the next line), hoping to find a connection between the resulting decimal numbers and the position of letters in the alphabet.

Sadly, I couldn't seem to get any joy here. I'm not about to embark on attempting every possible variation on the above.
User avatar
Graeme Cole
Series 65 Champion
Posts: 2025
Joined: Tue Jul 06, 2010 9:59 pm

Re: Code Puzzle

Post by Graeme Cole »

Matt Bayfield wrote:I noted that the image is a 36 x 36 grid, and if I replaced the black squares with 1, and white with 0, I ended up with 36 lines of binary (seems more logical than setting black = 0, white =1, given the large areas of white space). I then tried breaking down each line into groups of n bits (ideally where n is a factor of 36, for neatness, but this doesn't necessarily have to be the case, if you allow run=on to the next line), hoping to find a connection between the resulting decimal numbers and the position of letters in the alphabet.

Sadly, I couldn't seem to get any joy here. I'm not about to embark on attempting every possible variation on the above.
Here's the grid in machine-readable form, if anyone wants to do their own computery experiments on it (black=1, white=0):

Code: Select all

000111010010001000000000110001011110
101001000000001010101011001010100011
000000001100011000110001000000000010
000000010110010010100111001010000000
010010011100000000000100001010001000
110111000000000111010010001000000000
110001011110101001000000001010101011
001010100011000000101101000010011000
010110000000101101010010100111010000
000000100111001010011100000000000110
000010100111100101000000011110011100
000000110001011110101001100011000000
010000001010000010001000110111000000
000111010010001000000000110001011110
101001000000001010101011001010100011
000000011010010010011000010110000000
100111010000010010100101000000010110
010010011100001000000000011110001100
000000000110011110101101110111000000
101100001010011000011000110101000000
101101001010000000000110000010011100
000000001000011110000000010010100111
110100000000101100001010000000010110
011100011110101101000000010000011110
101101110100000000010001001100000000
110001011110101001000000011100001010
101011001010100011000000001000010010
001000110101000000110001011110101001
000000100101010000011110101001011000
001000110100000000100110010000001010
100101001010000000100111010000010010
011100001110100101000000000010100011
001010000000001100101001011100000000
000010011100001000000000001100101001
011100000000010010100101000000001110
011110011110001000110100000000000000
There are 855 white squares and 441 black. This leads me to believe it isn't just ASCII text encoded in binary - if it were, I'd expect there to be a roughly equal number of 1s and 0s. Actually there'd be slightly more 0s because the most significant bit is always 0 in ASCII, but I wouldn't expect nearly twice as many.

I converted it to ASCII anyway to see what would happen, and it was all complete gibberish. Same goes if I transpose the matrix. The pattern reminded me of something you might see in Conway's Game of Life, but applying that to it doesn't seem to give anything useful.

It's a 36*36 grid, so that suggested to me that six was important somehow. I thought it might be Braille, with the grid divided up into 2-column by 3-row cells, but even on the first row you get patterns that aren't valid in Braille.
User avatar
JimBentley
Fanatic
Posts: 2820
Joined: Fri Jan 11, 2008 6:39 pm
Contact:

Re: Code Puzzle

Post by JimBentley »

Matt and Graeme both have the right idea. I can give a couple of clues if necessary, but don't want to be premature in case anyone's still trying to crack it.
User avatar
Steve Balog
Acolyte
Posts: 168
Joined: Fri Apr 15, 2011 12:18 am
Location: neither here nor there

Re: Code Puzzle

Post by Steve Balog »

I've been trying to apply binary logic (AND, NOT, XOR) to various pairs of bits and getting nowhere. Hmmmmm.
There are no such things as methods. Only madness.
Ryan Taylor
Postmaster General
Posts: 3661
Joined: Sun Oct 25, 2009 6:18 pm

Re: Code Puzzle

Post by Ryan Taylor »

So anyone done anything more on this? I haven't because I know I can't. Answer possibly? Or a clue, Jim?
Liam Tiernan
Devotee
Posts: 799
Joined: Thu Jun 04, 2009 5:12 pm
Location: Kildare, Rep. of Ireland

Re: Code Puzzle

Post by Liam Tiernan »

Does it involve converting binary to hexadecimal?
User avatar
JimBentley
Fanatic
Posts: 2820
Joined: Fri Jan 11, 2008 6:39 pm
Contact:

Re: Code Puzzle

Post by JimBentley »

OK, a few clues (which may or may not help):

- Hexadecimal is involved;

- The lines are a fixed length for a reason;

- The correct answer contains 214 characters;

- A character can be a upper-case letter, a lower-case letter, a punctuation mark or a space.
Andrew Feist
Enthusiast
Posts: 462
Joined: Sun Apr 05, 2009 10:43 pm

Re: Code Puzzle

Post by Andrew Feist »

214*6=1284, so presumably that explains the 12 zeroes at the end. When I get tired of grading statistics papers (which probably won't take very long) I'll take an actual look at the data.

EDIT: If you do it in groups of 6, you get a lot of things that could be words with 000000 in between them (there are 47 such strings of zeros, which would lead to a message of 48 words). There are only 28 other strings that appear (out of the possible 64), so that could easily be letter+punctuation. We'll see if treating this like a cryptogram gets us anywhere, although at the moment that ignores the line-length information.
Andrew Feist
Enthusiast
Posts: 462
Joined: Sun Apr 05, 2009 10:43 pm

Re: Code Puzzle

Post by Andrew Feist »

Just for the fun of putting it in a new post: using 0's as spaces as above, it was pretty easy to find that 2=a and 10=e, and making the leap that "hey why not have every letter be represented by 2*n" almost worked; allowing for the possibility of 2*n-1 (represented by capitals below) gives:

Code: Select all

Did Yo
U eVeR
 flY a
 kiTe 
in bed
@ Did 
YoU eV
eR Wal
k WiTh
 Ten c
aTS on
 YoUR 
head@ 
Did Yo
U eVeR
 milk 
ThiS k
ind of
 coW@ 
vell@ 
We can
 do iT
@ ve k
noW ho
W@ If 
YoU ne
VeR di
d@ YoU
 ShoUl
d@ she
Se Thi
ngS aR
e fUn 
and fU
n iS g
ood@
where I've represented all the >52 numbers by @ signs, which should be punctuation. I've not quite worked out why the capitals are where they are, nor why it's "vell" and "shese".

EDIT: Oh and thanks to Graeme for posting the transcribed version. Looking it up (because I didn't recognize the text :roll:) tells me it's from One Fish Two Fish Red Fish Blue Fish by Dr Seuss.
User avatar
JimBentley
Fanatic
Posts: 2820
Joined: Fri Jan 11, 2008 6:39 pm
Contact:

Re: Code Puzzle

Post by JimBentley »

Excellent! I was a bit concerned that I'd arsed something up with this (I did as it happened, of which more later), as I just wrote a little program to construct the grid and didn't check it thoroughly afterwards, but it worked out OK enough to be solvable, which is a relief.

WARNING: Long post follows, much of which may make scant sense and is quite boring.

Some time ago I found a load of my old ZX Spectrum tapes from the 1980s and got the old programs working on a PC Spectrum emulator, including some routines I wrote when I was attempting (unsuccessfully) to learn Z80 machine code. One of them was for a text compression routine; I figured that you didn't need all 8 bits of a byte to represent text, just 6 would do (actually just 5 would do if you were happy to go ALL CAPS but that was a bit unreadable). So the idea was that text could be converted into 6-bit blocks, then read into memory consecutively across bytes, meaning that 8 characters could be stored in 6 bytes (48 bits) instead of 8 bytes, giving a 25% memory saving!

Needless to say, it didn't work very well. OK, it worked, but by the time I'd finished it I'd realised that there were better ways of doing it, such as representing common English letter groups ("the", "and", "sh", "ent", "ant" etc.) as one bit, which would give far more compressoid action, but I'd sort of lost interest in the whole thing by then.

Anyway, Andrew has it as spot-on as I think is possible from the information provided (the problem is that it's not possible to infer which values represent all the characters due to my aforementioned arse-up).

Each group of six squares represents six bits, so 000001 = decimal 1, 000010 = 2 and so on to 111111 = 63. The sequence (reading left to right, top to bottom) should resolve to:

7-18-8-0-49-30-41-0-10-43-10-35-0-12-24-49-0-2-0-22-18-39-10-0-18-28-0-4-10-8-55-0-7-18-8-0-49-30-41-0-10-43-10-35-0-45-2-24-22-0-45-18-39-16-0-39-10-28-0-6-2-39-37-0-30-28-0-49-30-41-35-0-16-10-2-8-55-0-7-18-8-0-49-30-41-0-10-43-10-35-0-26-18-24-22-0-39-16-18-37-0-22-18-28-8-0-30-12-0-6-30-45-55-0-44-10-24-24-53-0-45-10-0-6-2-28-0-8-30-0-18-39-52-0-44-10-0-22-28-30-45-0-16-30-45-52-0-17-12-0-49-30-41-0-28-10-43-10-35-0-8-18-8-53-0-49-30-41-0-37-16-30-41-24-8-52-0-38-16-10-37-10-0-39-16-18-28-14-37-0-2-35-10-0-12-41-28-0-2-28-8-0-12-41-28-0-18-37-0-14-30-30-8-52

The full list of character assignments was:

0 = space, 1 = A, 2 = a, 3 = B, 4 = b, 5 = C, 6 = c, 7 = D, 8 = d, 9 = E, 10 = e, 11 = F, 12 = f, 13 = G, 14 = g, 15 = H, 16 = h, 17 = I, 18 = i, 19 = J, 20 = j, 21 = K, 22 = k, 23 = L, 24 = l, 25 = M, 26 = m, 27 = N, 28 = n, 29 = O, 30 = o, 31 = P, 32 = p, 33 = Q, 34 = R, 35 = r, 36 = S, 37 = s, 38 = T, 39 = t, 40 = U, 41 = u, 42 = V, 43 = v, 44 = W, 45 = w, 46 = X, 47 = x, 48 = Y, 49 = y, 50 = Z, 51 = z, 52 = . (full stop), 53 = , (comma), 55 = ?, all other values unused.

As eagle-eyed viewers will have noted, I completely forgot to assign a lower-case q, which messed up the values towards the end of the alphabet - that's why Andrew's solution contains "shese" instead of "these" and all the strange capitalisations, there was no way he could know that I'd skipped a letter and definitely no way the values for punctuation marks could be guessed, which is totally my fault. Apologies if it put anyone off-track.

Translating the number sequence according to my fucked-up rules gives the 214-character string:

Did you ever fly a kite in bed? Did you ever walk with ten cats on your head? Did you ever milk this kind of cow? Well, we can do it. We know how. If you never did, you should. These things are fun and fun is good.

It is indeed a passage from Dr. Suess's "One Fish, Two Fish, Red Fish, Blue Fish" (as Andrew says). Nice work, man! You got it despite my mistakes, so 1,296 house points to you.
User avatar
Jon O'Neill
Ginger Ninja
Posts: 4545
Joined: Tue Jan 22, 2008 12:45 am
Location: London, UK

Re: Code Puzzle

Post by Jon O'Neill »

That's awesome. I think the backstory and fuck-ups in the code make this puzzle an all-time classic.
User avatar
Matt Morrison
Post-apocalypse
Posts: 7822
Joined: Wed Oct 22, 2008 2:27 pm
Location: London
Contact:

Re: Code Puzzle

Post by Matt Morrison »

That is quality.
User avatar
Charlie Reams
Site Admin
Posts: 9494
Joined: Fri Jan 11, 2008 2:33 pm
Location: Cambridge
Contact:

Re: Code Puzzle

Post by Charlie Reams »

This made me happy.
Andrew Feist
Enthusiast
Posts: 462
Joined: Sun Apr 05, 2009 10:43 pm

Re: Code Puzzle

Post by Andrew Feist »

The punctuation would be easily inferable if I had bothered, I think (or just looked up what it was supposed to be) -- that's how the whole thing got started anyway, so you might as well keep guessing.

I got stuck somehow thinking that the capitalized letters were important to the message somehow, and it never quite clicked that the pattern was really "these are all the letters that follow q in the alphabet"; had I noticed that, the rest could have been fixed (not that I would have known why the code suddenly changed at q, but I should have figured out that it did).
User avatar
Jon O'Neill
Ginger Ninja
Posts: 4545
Joined: Tue Jan 22, 2008 12:45 am
Location: London, UK

Re: Code Puzzle

Post by Jon O'Neill »

Andrew Feist wrote:The punctuation would be easily inferable if I had bothered, I think (or just looked up what it was supposed to be) -- that's how the whole thing got started anyway, so you might as well keep guessing.

I got stuck somehow thinking that the capitalized letters were important to the message somehow, and it never quite clicked that the pattern was really "these are all the letters that follow q in the alphabet"; had I noticed that, the rest could have been fixed (not that I would have known why the code suddenly changed at q, but I should have figured out that it did).
I agree. You can't really claim it as a perfect solve.
User avatar
JimBentley
Fanatic
Posts: 2820
Joined: Fri Jan 11, 2008 6:39 pm
Contact:

Re: Code Puzzle

Post by JimBentley »

Andrew Feist wrote:The punctuation would be easily inferable if I had bothered, I think (or just looked up what it was supposed to be) -- that's how the whole thing got started anyway, so you might as well keep guessing.

I got stuck somehow thinking that the capitalized letters were important to the message somehow, and it never quite clicked that the pattern was really "these are all the letters that follow q in the alphabet"; had I noticed that, the rest could have been fixed (not that I would have known why the code suddenly changed at q, but I should have figured out that it did).
Heh. I'm still impressed that you solved it at all. If I'd been really evil (as I'd planned originally) and completely randomised the letter assignations (e.g. 0 = R, 1 = f, 2 = z, 3 = M etc. or similar) would that have made it completely unsolvable, do you think? My instinct was that it would have done (which is why I didn't do it in the end) because the passage is too short, but I'm wondering about that now.
Andrew Feist
Enthusiast
Posts: 462
Joined: Sun Apr 05, 2009 10:43 pm

Re: Code Puzzle

Post by Andrew Feist »

JimBentley wrote:
Andrew Feist wrote:The punctuation would be easily inferable if I had bothered, I think (or just looked up what it was supposed to be) -- that's how the whole thing got started anyway, so you might as well keep guessing.

I got stuck somehow thinking that the capitalized letters were important to the message somehow, and it never quite clicked that the pattern was really "these are all the letters that follow q in the alphabet"; had I noticed that, the rest could have been fixed (not that I would have known why the code suddenly changed at q, but I should have figured out that it did).
Heh. I'm still impressed that you solved it at all. If I'd been really evil (as I'd planned originally) and completely randomised the letter assignations (e.g. 0 = R, 1 = f, 2 = z, 3 = M etc. or similar) would that have made it completely unsolvable, do you think? My instinct was that it would have done (which is why I didn't do it in the end) because the passage is too short, but I'm wondering about that now.
Since a was a single-letter word and e was by far the most common letter, those would still have worked. Since all the words were so short (even if you figure out i?, you still have is, it, in to go through and try), that made it a lot harder to get much farther without the pattern in the numbers, although I did have (well, guess) ever/never based on the letter pattern. I might have gotten lucky with the guesses, but I suspect I would still be working on it.
Post Reply