E2: The (NP-Complete) Kids’ Game with the $2 Million Prize |
The Eternity 2 (E2) puzzle has attracted the attention of puzzle fanatics, computer programmers, and mathematicians for many reasons, not the least of which is the $2 million prize for being the first to solve it. E2 is an edge-matching puzzle with 256 pieces. The general class of edge-matching puzzles is known to be NP-Complete, but it is unknown if there are aspects of E2 that can be exploited to make it tractable. In the spirit of cooperation, a few people have made their automated solvers available online, and I have provided an overview and back-of-the-napkin analysis of two of them.
Background
E2 has 256 square pieces that must be placed on a 16×16 grid. Each puzzle piece has 4 edges, each with one of 17 possible patterns, which must match the pattern of the neighbor piece that touches that edge. Each of the edges touching the border must be gray. There is also one hint piece which must be placed on the board at the indicated position and orientation.
The animation below shows a methodical approach to solving a 4×4 puzzle with no hint piece. Pieces are taken from the right side and placed on the board on the left. When a dead end is found and no more pieces can be placed on the board, pieces are removed up until the last decision point and a new piece is tried at that spot. The algorithm you are seeing in action is a backtracker.

Clues & Rules
An additional hint is provided for solving each of the 4 clue puzzles, for a total of 5 possible hints. E2 clue puzzles I and III are 6×6, and E2 clue puzzles II and IV are 6×12. Clue puzzles III and IV are only available in the UK as of this writing. It is not required that the E2 solution use these optional hints, and it is suspected that E2 has more than one possible solution.
In order to win the $2 million prize, submit the solution to the Eternity 2 adjudicators by December 31, 2008. On the 31st, all entries will be opened and the entry that was submitted first wins the $2 million. If nobody submitted a complete solution, the competition will continue until December 31, 2010. A smaller prize may be awarded for the highest scoring partial solution if no complete solution was submitted. The complete rules can be found on the official site.
Sounds easy right? Well…
Solver Implementations
A few solvers have been made available online in the files section of the E2 Discussion Group. I picked two of the most straightforward solvers and ran benchmarks on them.
The first solver I looked at is Doc Smith’s C++ solver which is based on a solver by Marc Lebel. Doc’s solver works by first creating arrays that list the pieces that will have given colors on certain edges. This means that finding a piece with, say a green left edge and a red top edge, requires indexing the 2 dimensional array storing left and top matching pieces with the code for a green edge and the code for a red edge. The solver works by starting at the top left corner and tiling towards the bottom right corner (just like in the animation above), so there is no need for an array that would contain matches for say, only top and bottom edges. If the solver reaches a dead end, it backtracks recursively to the last decision point and tries again. Once the solver reaches the lower right corner, a solution has been found.
Next I looked Joel’s solver which is a Java port of the C++ backtrack solver written by Doc Smith. These two solvers work the same way; they differ only in the implementation language.
The E2 Discussion Group is very active and contains a lot of information on different solving strategies, so if you are interested in more advanced algorithms, have a look there.
Benchmark Results
I ran benchmarks on both solvers to compare their performance. The benchmarks are puzzles similar in design to E2, but of a smaller size. I ran benchmarks on 6×6 with 1 hint, 8×8 with 2 hints, and 10×10 with 3 hints puzzles to get an idea of what kind of complexity we can expect from E2. All of the benchmarks were run on a dual core 2.00Ghz Intel with 1 GB of RAM. No compiler optimization flags were used for any of the test runs.
Here is a table giving the mean solution time for each of the solvers (the benchmarks had more than one possible solution, so I used the mean time in the table). On the 10×10 benchmark, I stopped the test after 10 hours. Neither of the solvers had found a solution at the time. The complexity of the puzzle increases exponentially in the number of pieces - this is to be expected of an NP-Complete problem.
| 6×6 | 8×8 | 10×10 | |
| Doc Smith | 891 msec | 91 min | 10+ hours |
| Joel | 790 msec | 107 min | 10+ hours |
One mildly surprising result is that the Java solver outperforms the C++ solver. Enough to make a difference solving the 16×16 E2 puzzle? Not likely. At this rate it would take more than a lifetime to find a solution for the 16×16. Improving the solving algorithm will give much better gains than code-level optimizations.
So will you get rich solving E2? Well, somebody will. If this type of challenge interests you, its definitely worth a shot.
Resources:
Purchase E2 from Amazon
[Disclaimer: Links to amazon.com are affiliate links.]
Related |
|







A Guide to Eternity 2 Solution Finders | GrokCode…
The Eternity 2 (E2) puzzle has attracted the attention of puzzle fanatics, computer programmers, and mathematicians for many reasons, not the least of which is the $2 million prize for being the first to solve it….
Very Nice Post The Eternit 2 (E2) puzzle has attracted the programmers and mathematicians because i hope this is the first puzzle whose prize is $2 million.
[...] j presents E2: The (NP-Complete) Kids’ Game with the $2 Million Prize posted at GrokCode, saying, “A look at the geeky Eternity 2 (E2) puzzle game, and different [...]
These algorithms do not seem really efficient, a basic prolog brute force one achieves better performances. I assume it is because of the built in backtrack.
@/\/ The recursive algorithm may be causing a performance hit. I’m curious how much faster the prolog test ran? Also, I’m not exactly testing on a state of the art box, so if your test is running on better hardware, that could be causing the difference.
The Eternit 2 (E2) puzzle is very famous because of it’s prize is $2 million prize for being the first to solve it.
keep up your good work
I will be a regular reader of ur blog
I haver order the game, but it will take 2-3 weeks to arrive. Does anybody has a list of the pieces in a txt file? I will be very gratefully mcubel@gmail.com
My new (not finished) solver outperform these benchmark results… Solver is implemented in Delphi.
bench 8×8 in 246 seconds! http://img218.imageshack.us/img218/8536/bench8×8pi5.jpg
[...] presents E2: The (NP-Complete) Kids’ Game with the $2 Million Prize posted at [...]
My solver has solved 10×10 in seconds, but sometimes it takes minutes
With one hint piece, 5 edge types, 18 center types.
It solves about 2-6 million pieces at second on Intel Core 2 Duo 4300.
Java is great
Hi there,
I found great ideas and discussing on your Web site.
Well done ! Thanks for that and keep on doing
Greetings from germany , Thomas
P-E-X How long it takes to solve 10×10 with 3 hints? And the 8×8 with 2 hints? (With the puzzle definition used here in GrokCode benchmarks)
After tuning and optimizing my code, I dropped solving time… example: 8×8 2 hints from 246 seconds (see above) now in less than 5 seconds! Starting with 4 possible corners in a quad core and 9-10 million pieces/second performance solver, invalid starter corner detected in less than 81 seconds and a solution found in 5 seconds with right corner.
http://img193.imageshack.us/img193/4313/grok8×82hints.jpg
but Eii is impossible
I benchmarked my solver. I don’t have ms timing (aiming for high) and mine supports only one hint piece (still under development)
All test were run on single thread, no multithreading supported at the moment, on Core 2 Duo 4300 1,8ghz
50 Runs 8×8, one hint piece, 5 border types, 18 center types:
All 50 runs took less than second, timer was always: 0 seconds
50 Runs 10×10, one hint piece, 5 border types, 18 center types:
- Most of runs took less than second to complete.
- Longest run: 39secs
- There were only few of those long runs 39, 26, 8 secs all other where lesser than that.
- Average time: 3,08 sec for 50 runs.
Use the power (of the algorithm)
Mine has always correct corner piece
I started six runs on 11×11 (not same data), one hint piece, 5 border types, 18 center types took… One have completed: 2 min 43 sec, but others may take hours or days… not waiting those… 10×10 has only 100 pieces… 16×16 has 256… and each increase 1-10 times the time needed for solving, so lots of improvement has to happen before Eternity 2 is solved.
Board size (pieces quantity) is not the main cause of complexity, the pieces types and patterns quantity are more determinant.
Please run your solver with these pieces/patterns and use the first hint only:
http://grok-code.com/downloads/B8×8With2Hints.txt
I bet it takes more than a second to solve it. ^^
Aah, now i saw the testdata. I need to make little modifications to code for the hint piece. Offcourse with this data it will take more time to complete, but i am pretty sure that it will be more efficient than Doc Smith or Joel algorithms.
Haven’t got time to work with the solver, but with random data 8×8 table and 1 one hint piece i waited few hours without result. dPUNiSH3R your algorithm can handle in about 3 minutes? That’s fast…
P-E-X if you review my post you will see that my results were using the 2 hint pieces. (”8×8 with 2 hints” benchmark used here)
Summary of my results:
2 hints: starting with right corner then 5 seconds to solve, starting with a no solution corner then 120 seconds to detect no solution. http://img193.imageshack.us/img193/4313/grok8×82hints.jpg
If I use only 1 hint (the first hint): starting with right corner then 16 minutes to solve, bad corner then 164 minutes to detect no solution.
http://img20.imageshack.us/img20/6752/grok8×81hint.jpg
I run my solver using 4 instances running in parallel (in a quad core), each instance with a different corner piece fixed (4 possible), so I solve it in 5 seconds with 2 hints, and 16 minutes with 1 hint.
Use the same test puzzle for a better comparison.
6×6 puzzle can be solved in few milliseconds… about 150ms between values where 1 - 300ms.
but 8×8 wasn’t finished after 5 hours on single core. I think i must look the loading algorithm if there is something wrong.
dPUNiSH3R your algorithm can solve 8×8 with only 50 million tests?