New solve(grid) and is_valid(grid) functions

Many improvements, especially a new brute-force solver that generates
all possible valid solutions and a validator to test the validity of
puzzles and solutions.