Algorithm for solving sudoku puzzles