This is a simple sudoku application consisting of a sudoku generator and sudoku solver from a sudoku lover.
- Sudoku class allows you to create different sized sudokus and check for validity.
To generate a Sudoku s of size (n, n), Starting from (row,col)=(0,0):
- Get pos: the set of possible numbers for s[row,col].
- While pos is empty, return to the previous state of generator.
- If pos has a single entry assign it to s[row, col], otherwise pick one and assign it to s[row,col] and save the state(grid before assignment, row, col, other entries in pos, number of filled entries in the grid).
- Repeat [1-3] for all indices (row, col) in sudoku grid.
Given a Sudoku of size (n,n) with m empty slots, SudokuSolver
- Identify possible numbers, possibilities, for each (r,c) such that sudoku[r, c] is empty.
- Find the index (r,c) with the least number of possible numbers (if there are multiple such (r, c) return the first one).
- If possibilities[r, c] has a single entry pick it as num otherwise, pick one of them as num and add the last state of the solver to the stack .
- Try assigning num to [r,c]. If the guess is not valid return to the previous state of the solver.
- Repeat [2-4] until all entries are filled in the sudoku grid.
- Add difficulty level
- Implement a basic UI