How to make Sudoku solver with backtracking algorithm go back?
问题 This weekend I worked on a Sudoku Solver (Ruby quiz) based on a backtracking algorithm. The sudoku is loaded in an array sudoku_arr of 81 integers (9x9 grid) where 0's are empty spots. There is a valid? method which checks if the sudoku_arr can be a valid sudoku. The official backtracking algorithm goes like this: try value on next empty spot, check if it is valid sudoku, if not increase value by 1 (upto 9), if valid go on and try first value on next spot, if not increase value of previous 0.