Wednesday, July 20, 2011

Problem 96

I decided today to try and conquer problem 96 and it's proved to be a bit of a challenge. I've spent maybe 40 minutes on it and have made pretty good progress.

I figured the best thing to do was to read each puzzle number by number. By taking a solution matrix that was 81  x 9 (each row represents all of the possibilities of each square in the 9 x 9 puzzle) I replaced each possible number with a zero if it could not be a solution. So far I have only been able to eliminate each row and column that was already given a number from the .txt file. Now I'm going to figure out a way to eliminate each square from the given numbers, and then edit my loops a little bit to check when there is only 1 possible number left in each of the 81 spots. Finally, when there is only one number the process will repeat and eliminate these new choices vertically, horizontally and in squares.

Solving the first puzzle given (doesn't solve all the way, obviously) takes about 0.04 seconds and I'm afraid that my code will be VERY slow for 50 problems. Maybe I can find a way to break when I finish the top left numbers instead of solving the entire puzzle.

No comments:

Post a Comment