previous | start | next

Stack Application 2

Given a Sudoku puzzle, use a Stack and brute force to solve the puzzle.

At each empty position insert the first value in 1 - 9 that is valid, where valid means not duplicated in the same row or column or small 3 x 3 square. Push that value and position on the stack.

If none of the values 1 - 9 is valid, pop the stack, remove the value at popped position and try the next values.

Continue until all positions have been filled.



previous | start | next