Christmas time can be stressing with all the necessary shopping that is involved. If you are still clueless about what to buy for the nerd close to you, here's a thought: Eternity II. It's a jigsaw puzzle of 256 pieces and being the first to solve it will earn you $2M in cash. Whether it is a good gift idea, I will let you decide. Instead, I will focus on analyzing the problem a little to give you an insight of the true nature of the puzzle.

Image 

Shortly put, there are 256 pieces which are all square, and if I understand correctly, 22 different colors. The 4 edges of each piece are colored differently and you need to create a 16x16 grid of the pieces so that all the adjoining edge colors match. It is like the Tetravex PC game, but the pieces can also be rotated. Just see the website for a demo, you'll get it in a second.

I understand that the puzzle has been one of the hits of this year and I can see why. There are many people who routinely enjoy themselves with puzzles of 1000 or 5000 pieces, so how difficult can one with only 256 pieces be? Well, VERY HARD, as in the word IMPOSSIBLE. The main reason is that the puzzle is lacking both of the two properties that a "normal" jigsaw has. First, an usual jigsaw puzzle is made of a photograph or a painting, so even without a small-sized hint picture you can quickly distinguish sky and ground pieces apart and make a rough classification where each piece should go. Second, the pieces have small extruding "tabs" and gaps which give away the information of when a proper connection of two pieces has been made. Eternity II has neither of these properties. By all accounts, any natural method of trying to solve Eternity II is by trial-and-error and seems to require going through all the possible combinations. For solving by hand, the puzzle is just overwhelming and I'll try to describe why.

The programmer in me just screamed to note that this is the perfect place for writing a solver that does the job, so I did. But before concentrating on the program, let's do some analysis on the difficulty of the puzzle. We are mainly interested in the scaling of the complexity of the problem, so let's not only look at the 16x16 case, but the smaller versions also. If we denote by %$N$% the number of pieces along one side, i.e. the whole puzzle is %$N$x$N=N^2$% pieces, we get a formula for the number of possibilities %$S_N$% we need to check, %$S_{N}=N^2!\cdot (N^2)^4$% (with special information about the puzzle we can do a little better, but for the sake of clarity, I don't bother). For different values of %$N$%, this yields the following table:

%$N$% %$S_N$% 
 4 %$1.37e18$%
 5 %$6.06e30$%
 6 %$6.25e47$%
 7 %$3.51e69$%
 8 %$2.13e96$%
 9 %$2.50e128$%
 10 %$9.33e165$%
 11 %$1.74e209$%
 12 %$2.39e258$%
 13 %$3.48e313$%
 14 %$7.50e374$%
 15 %$3.23e442$%
 16 %$3.68e516$%

 You can see that already with very small sizes, that's a lot of space to search. The largest I've ever managed to solve is 8x8, which took a day and lots of luck. The complexity is more than exponential (it is of order %$x^x$% due to the factorial function). But how big is %$3.68e516$% exactly and what does it imply for solving the problem? To get a grasp of this number, I estimated the following. The program I wrote searces through 20M states per second on my 1.6GHz laptop. It is not bad, but it's definitely not the fastest you could do. Suppose we had a fast optimized program that could do 100M states per second. The question we're interested in is that how long does it take for such a program to exhaust the search space? A simple calculation gives us %$\small{\frac{3.7e516}{100e6}}$ $\approx 1.2e501$% years! Obviously we need to do a lot better, so let's assume we distributed our search over to several computers, say to 6.6 billion computers (one for each person on earth!) and assume that each of those were an IBM supercomputer equal to 100x the speed of my laptop. Let's further assume that the solution was not at all unique (which it probably isn't), and there is a huge number, like, %$10^8$% different solutions. That would still leave us with %$1.8e481$% years of computation! But surely we can get lucky and don't need to go through the whole search space, so what is the probability of us finding the proper configuration in the three years that the contest is running? The answer is %$5.9e-480$%. It is estimated that the whole universe contains only %$10^{80}$% atoms, so that is the equivalent of finding a single atom from six parallel universes, or winning the lottery jackpot 48 times in a row!

The above estimation is far too simplistic in the sense that it just bluntly examines all the ways to build the puzzle. Of course we don't need to first build the whole puzzle and only then see if it was correct. Instead, we build the puzzle piece by piece, discarding all obviously incorrect placements as we go and back up to an earlier state when we hit a dead end. This is the idea behind backtracking search, which explores the state tree systematically by pruning the branches as soon as they are found impossible. This leads us to ask, how efficient improvement is this kind of "intelligent brute-force" search? What is the expected running time of this algorithm? To this end, I wrote a program that would give me the answer.

%$N$%Time to solve 
 316 msecs
 494 msecs
 58.6 secs 
 622.4 mins
 72.2 days
 81074 years
 9543000 years
 102.9e10 years
 114.9e14 years
 121.4e19 years
 136.0e24 years
 141.8e32 years
 152.8e40 years
 163.6e49 years


The program estimates how large parts of the search tree get pruned at each iteration and calculates a "virtual" search speed as nodes/second. This lets us create a progress counter that somewhat reliably tells how long it takes to exhaust the whole search space. The time estimates are shown in the above table. It's quite interesting: %$3.6e49$% years is a lot less than the %$1.2e501$% we began with. But does this get us even close to solving the problem? Well, what do you think?

Image

Following the same thoughtplay as for the brute-force case, if we distribute the search over to 6.6 billion computers, each 100x the speed of my laptop and suppose we have %$10^8$% solutions, we get "only" %$5.5e33$% years. This is a lot less than the number of atoms in our universe, but the probability of succeeding in the search in 3 years is %$5.5e-34$% which equals the probability of winning the lottery 4 times. That's a huge improvement, but those were rather big "ifs" too. And if you could have 6.6 billion computers, you would have spent more than $2M on electric bills alone so it doesn't look too bright.

Ok, now you think Eternity II really is unsolvable, or at least I hope you would. I'd like to say too that the chances are zero, but I wouldn't place any bets on either way. The nature of the puzzle doesn't offer too much hope for finding a more efficient algorithm and the whole game is just too close to the heart of the %$P\neq NP$% issue. Well, the first Eternity puzzle also seemed impossible, but still some people figured out a way. This time though, I'm not sure if anyone really can. In any case, if you liked the gift idea, I suggest that you also buy a set of marker pens to-go so that whomever poor chap you give it to can at least attain the mental satisfaction of seemingly solving it.

Last Updated (Thursday, 20 December 2007 14:54)