For Christmas my son was given one of those puzzles where you have to place tiles next to each other in a square so that the symbols on the touching sides match. This particluar one is called "The Valley of the Kings" and is published by PuzzleAdventure. As soon as I saw it I thought, this is going to be far easier to solve by computer than by hand.
I've just got round to putting together a Java program to produce a solution. I picked Java over perl or python or scheme mainly because I could use IntelliJ for development. I must admit Haskell was tempting as there are no IO requirements, just algorithms. On the other hand, I'd have had to spend a lot of time with the manual just to deal with the syntax, as I've not used it for so long, and was never very familiar with it in the first place.
It took about two hours to write the program using IntelliJ. I implemented a very simple brute force approach. It just starts in the top left and recursively tries each tile in each possible orientation in turn until it finds a solution. When a solution is found an exception is thrown to take the solved layout back up to the top level. As it finds the correct solution in 656 milliseconds it turns out it's not worth performing any optimization.
Personally I found writing the program to find the answer a lot more fun than trying to find the answer by hand but it's probably not what the puzzle makers had in mind.
Posted by Alex at April 22, 2003 09:46 PM