I understand the basic method of generating sudoku puzzles, which is:
- Put a random number in the current square.
- If the puzzle is still valid, go to the next square. Otherwise, stay on the same square.
- Repeat from step 1.
However, sometimes a sudoku puzzle gets "stuck" so that no matter what you put in the square, it still won't work.
How can I avoid getting stuck in an infinite loop here?