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?
I had to make major modifications to algorithm. First i had a rotating table which worked, but was not efficient enough multiple cores and fixed start pieces seem to be the way. I had also randomization bug (pieces were not rotated). Last i had loading problem for test data. Now almost all features are implemented and working. So better results are comming
Grok 8×8 with 2 hints (Piece order is randomized and randomly rotated)
Six runs average 26 min (Min 10 - Max 52)
With correct corner piece best time is 3,30 min
As my daughter and I eagerly unwrapped the package our copy of Eternity II came in we couldn’t wait to rip off the cling film and get going. Four hours later we were still at the dining table having zoomed ahead on several occasions, only to find ourselves having to backtrack again.
The feeling is just like when you find you have one stray white cube in the middle of a face of green squares on your Rubics Cube…
Hi,
I must be missing something here. For the Grok 8×8, starting with a particular corner and ignoring hints I make the number of possible branches after placing 24 further tiles to make a 5×5 square approximately
8^3 x 7^3 x 6^2 x 2^16 = 414 billion
so even solving at 10 million branches per second would take several hours?
What am I missing?
Chilly, you don’t have to check all possible combinations, only those which can be possible… like Corner pieces must be at the corner (4 start pieces, no need to check pieces 5-64 and all of their combinations where those pieces are at the corner)… piece next to current piece must have the same edge…
P-E-X. Thanks for your reply. Yes, I was allowing for that. For the grok 8×8 there are 24 edges but only 3 different colours, so on average 8 possible candidates for first 3 edges, then 7 for the next 3. For centre pieces where you already have 2 sides to match the expected number of candidates is 34 (pieces left) x4 (rotation) /8^2 = 2.125, since there are 8 different colours on centre pieces, hence the 2^16 in my formula. I threw together some code to do a recursive backtrack and that verified my numbers. I think the answer is that the hint pieces reduce the number of nodes (by piece 25) from 400bn by a factor of 8^4, so to around 100m. I found a paper that suggests most alogorithms handle around 4m nodes per second, so with the hints the run-time is OK. But I still don’t understand how dPUNiSH3R can solve in 5 secs. Implication is that there are some short cuts, which is what I’m interested in.
I tried this game once, but just didn´t get it. So how could you possibly solve this in 5 secs?
In 5 seconds????
I´ve no chance. I could not see and click so fast.
I read a few descriptions about this puzzle and apparently each of the 256 pieces are numbered on the back. I assume these have been ‘randomly numbered’ which may represent an easy solution to the puzzle namely computers don’t do random very well, standard procedure for randomness is to use the clock cycle as a ’seed’ I’m not a cryptographer but I would be willing to bet there is a pattern in the resulting numbers generated.
Anthony is on to something.
Take add in all the clue pieces and the easter egg on the box, and you have around 16 free pieces placed.
If a pattern could be discerned from those 16 fixed locations, one could unrandomize the numbers and find the solution Monckton used as start point.
Les in Ashburn,
What easter egg on the box? How did you get 16 fixed locations? I Have the main one in the middle and the four clue puzzle ones.
I bought E2 this weekend. I’ve noticed with mine that each half shape is not perfectly cut, so when joined together they do not make symettrical shapes, however there seems to be a father and mother piece which seems to make it a little easier when looking for a specific colour, for instance, The yellow circle with the purple cross is not symmetrical when two pieces put together, however you can discount all the larger pieces needed to complete the cross, or am I wrong and was just V. unlucky to have a badly cut board?
Each piece is printed on the cardboard you punched them from, not next to the piece that they should match with. Symmetrical would not matter as long as the patterns match. All boards have some pieces that were cut a little bit off. Its nothing to worry about. Just dont look into the way they are cut too much as it does not mean anything.
If you are thinking the board like chess board… white and black places… in correct solution there must be equal number of each style piece in black and white places.
If somebody could sort these pieces to two piles (white & black) both containining equal amount of each style. That could be start for the solution.
Why would we assume that such a basic pattern as the one underlying a chess board (w/b/w/b/w/b…) is somehow related to eternity II ? Even if it was proven true, we wouldn’t be able to infer that we ought to have the same number of pieces in each pile. And even if that was the case, we would still have no idea of how to order the pieces.
For what we know, the placement pattern (in the sense that knowing it would give us the rules required to place the pieces into X piles) can be anything.
This was an idea…
X X X X
XW3 3B1 1W4 4BX
4 3 2 1
4 3 2 1
XB1 1W3 3B1 1WX
X X X X
Style White Black
1 4 4
2 1 1
3 3 3
4 2 2
Number of pieces must be even
X:s aren’t noted here because they dont got any pair.
Thoughts:
Maybe pieces could be sorted to two piles black and white. Then try to solve the piece locations. Number of possible pieces is only half of it used to be.
8×8x8×8x8 = 32768
But:
4×4x4×4x4 = 4096
This won’t guarantine solution because there may be multiple even sorts of pieces..
I didn’t mean to be aggresive
It’s always nice to see new ideas coming up
Code tag didn’t work as i thought… spaces are lost… There were eight pieces in 4×2 format…
_1_
2W3
_4_
P-E-X,
I am interested in what you are talking about, but I am not following what you are saying at all. Can you break down the meaning behind your last post?
My ascii art was raped by site
I mean that if board is divided to white and black places like chessboard.
Any of white pieces won’t touch any of white pieces and
any of black pieces won’t touch any of black pieces.
Thats why each white must have 4 black pair pieces and
yeah black piece must have 4 white pieces…
Thats pretty clear…
Now in Eternity II each complete pattern is divided into two pieces. In this case to white and black piece.
Thats why total sum of each pattern must be same in black and white pieces…
Now if somebody could sort these pieces really fast to even piles it could be found.
Another thing if the piles ain’t even the puzzle is unsolvable… (i used this in my solver, but not very good speedup… maybe with larger board it could help more)
How would solving for these two types of pieces be any faster than solving the puzzle itself? How would you define a piece so that it would fit ONLY into one of the two?
David in Atlanta,
I didn’t find a way to sort these pieces… But somebody may…
I don’t know how to sort sets…
If pieces are sorted the solving may be exponentialy more efficient….
8×8×8×8×8 = 32768
But when number of possible pieces is halved…
4×4×4×4×4 = 4096
At least this can be used to track faulty places pieces
I haver order the game, but it will take two weeks to arrive!!
dPUNiSH3R,
I read your results on the GROK 8×8.
It’s impressive that you found a solution in 5 seconds (with the right corner piece set).
But it may be that this was just by chance.
The fact that it takes 80 seconds to find out that/if there is no solution (with the wrong corner piece) is more interesting, since that means you exhaustively searched the GROK 8×8 in 80 sec (x4 for the possible corner choices).
I wonder if you made more progress since then (getting faster), and also which search order you use.
I also wonder if you found the second solution (my solver found 2 solutions, as part of a 25 sec exhaustive search).
With one hint, and exhaustive search of GROK 8×8 takes an hour. Same result : 2 solutions.
Also, I wonder if anyone managed to solve the GROK 10×10 (with or without the 3 hints) by now.
My solver was cranking on it for 2 days, with interesting results, but no solution.
I estimate that I searched only 1 % of the realistic (probably) solution space.
Thanks
Rob
Didn’t have time for eternity 2 during the last years and were suprized my solver is discussed here. By the way, there was an eternity I back in 1999 which was completely solved, there are 12 known solutions, 9 of them from me (unfortunately I wasn’t the first). After reviewing my eternity II code after 2 years I decided to rewrite the thing in Java - haven’t seen Joels work at that time. Some comments: New processors (I7, intel q9550) perform very good for Java, there is no more any performance penalty, specially if you use jdk-6u20-windows-x64.exe. 64-bit is about 30% faster, jdk-6u20-windows-x64.exe is 10% faster than jdk-6u14-windows-x64.exe
and much faster than jdk5 versions. Using 4 cores you can reach about 100.000.000 nodes per second on a 3.4 Ghz Q9550. Order of piece placemant is very important, specially if hint pieces are used. The whole search space can significantly be reduced, this explains the different results. The time for finding a solution is completely random - the time for searching the whole search space is not. The task for finding a “almost complete” but not perfect solution is completely different from the task searching for a complete solution - different techniques are required. I will try to write some code for this purpose.
After seeing Joels code: This is a one to one port of my C++ code, very similar to what I tried myself first. But after that I saw that the quite complex optimization which worked well for C++ doesn’t help in Java. So my new Java code is more similar to the original code of Marc Lebel, which suprizingly is about 10% faster than the one to one port - and almost the same speed as the original C++ version. A further modification is to support finding maximal partial solutions - as far as I know there was a 10.000 prize for finding a 467 correct edges partial last year. I allow with some small probability the placement of not completely fitting pieces during the search in order to get some promizing piece placements with only a few nonfitting edges, and then try to optimize these by exchanging pieces. Some data structures needed to be adapted in order to support this.
Hi guys, you’re doing a great job here!
Like you all, I decided to write my own solver and thought I could share some benchmarks for 5 border edge types, 17 interior edge types (like the original game):
9×9 table - average time: 2.5 seconds
10×10 table - average time: 155 seconds
What are the best times for these settings yet?
Problem probably cannot be solved for 16×16 but you don’t know until you try. What’s the best solver yet?
Regards,
Mihai
I tried to do this game what I`m too old to solve it, I think. Any advice how to get it solved ?