More Java posts
April 22, 2003
Is it cheating?

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
Comments
I don't think it's cheating; you worked out the puzzle on your own, just in an unconventional way. Cheating would be if you took the answer from someone else. Although your method was faster, I don't think it was easier. The reason it seemed easier to you, almost like cheating, is that you solved it in the way natural to you, the methods you use everyday in your work. That is, I think it is more difficult to clearly define the problem so that you can write a program to solve it than it is to physically move tiles around. Not everyone has your ability to abstract. Posted by: M Sinclair Stevens on April 23, 2003 06:56 AM
Hey - it's a toy. What *matters* is whether you are having fun. The notion of cheating only really matters when there are other people involved. Posted by: Simon on April 25, 2003 06:13 AM
I thought you would probably resort to your usual problem-solving methods. Surely you can't have been beaten by the guys at the Science Museum. I'll get a more difficult one next time! Posted by: mfm on April 30, 2003 03:43 PM
I am amazed at your ability too, not everyone has it. Would you be kind enough to share you solution code with me for educational purposes... thanks Posted by: andy on July 6, 2005 09:50 AM
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?