Eoin Davey.
Problem solver/creator.
SRE @ Google.
BSc. Computational Thinking.

The Fifth Puzzle: Snap!

Thanos’s fingers snapped and your puzzle answer dis-integrated into dust. But you are Antman, can you reassemble this dust back?

This puzzle presents us with an archive of 760 images and the challenge to put them back together again.

Puzzle 5 shards

The images are all 200x50 pixels. Presumably the answer to the puzzle lies in the pieced together image.

The Algorithm

We have a lot of choice in how we could approach this problem. I know for a fact that some solvers printed out the images and pieced together the image by hand. Some other solvers imported the images into GIMP or Photoshop and pieced them together manually that way. I want to do as little manual work as I can without overengineering the solution.

A lot of the complexity of a full automatic matching solution comes from keeping track of complex 2d collections of partially pieced together rectangles.

My approach was to automatically generate the rows and then I would match the rows by hand, a rough estimate of the number of rows assuming a roughly square final image is 20ish rows. That’s very easily done manually.

The algorithm to piece together the rows of the image is to choose a seed image and find it’s closest match on the right hand edge, combine those two and then continue on with the new right hand edge.


The metric I chose to tell how well 2 images matched along an edge was just the euclidean distance between the vectors of pixel values of the relevant edge of each image. This worked quite well. I’m sure better metrics exist but this did the job and was simple to code.

Manual work

If the program wasn’t sure about a match (high difference in the two sides) it would display the combined image for manual verification.


The program outputs well matched up rows of the image like this.

Puzzle 5 row 1

We can see there is a word in the image there, it appears to say prior

Generating more rows finds the other 2 words hidden in the image

Puzzle 5 row 2

Puzzle 5 row 3

It’s a bit hard to make out but the other 2 words are throughout and unofiicially. Puttting throughout unofficially prior into the guesseract solves this problem.

5 out of 6 solved! Onto the final puzzle.

Let’s move onto puzzle 6