A front-end sudoku generator and solver
Sudoku Solver and Generator - Coding Project
Build a complete Sudoku application that can generate puzzles, validate solutions, and solve puzzles using algorithmic approaches. The application should have both a command-line interface and a simple graphical interface.
1. Data Structure and Board Representation
- Implement a 9x9 grid using a 2D array or matrix
- Use integers 1-9 for filled cells and 0 (or null) for empty cells
- Create a SudokuBoard class with methods for:
- Getting and setting cell values
- Checking if a move is valid
- Displaying the board in a readable format
- Deep copying the board state
Implement comprehensive validation that checks:
- Row validation: No duplicate numbers 1-9 in any row
- Column validation: No duplicate numbers 1-9 in any column
- 3x3 box validation: No duplicate numbers in any of the nine 3x3 subgrids
- Complete puzzle validation: Verify a fully filled board is a valid solution
- Partial puzzle validation: Check if current state has no conflicts
Implement at least two solving algorithms:
Algorithm 1: Backtracking
- Find empty cell (value 0)
- Try numbers 1-9 in that cell
- For each valid number, recursively solve the rest
- If no solution found, backtrack and try next number
- Include optimization: choose cell with fewest possible values first
Algorithm 2: Constraint Propagation
- Naked singles: If a cell has only one possible value, fill it
- Hidden singles: If a number can only go in one cell in a row/column/box, place it
- Combine with backtracking for harder puzzles
Create a generator that produces valid puzzles with unique solutions:
- Start with a complete, valid Sudoku grid
- Remove numbers systematically while ensuring unique solution
- Support difficulty levels:
- Easy: 45-50 filled cells, solvable with basic logic
- Medium: 35-44 filled cells, requires some advanced techniques
- Hard: 25-34 filled cells, requires complex logical deduction
- Expert: 17-24 filled cells, may require trial and error
5. User Interface Requirements
Command Line Interface:
- Display board with clear grid lines and formatting
- Accept input in format "row,col,value" (e.g., "3,7,5")
- Commands: solve, validate, hint, new_game, save, load
- Show solving steps with timing information
Graphical Interface (choose one):
- Web-based (HTML/CSS/JavaScript)
- Desktop (Tkinter, PyQt, Java Swing, etc.)
- Features needed:
- Clickable 9x9 grid with clear visual separation of 3x3 boxes
- Number input buttons or keyboard input
- Solve, validate, hint, and new puzzle buttons
- Timer and move counter
- Highlight conflicts in red
File I/O:
- Save/load puzzles in a standard format (plain text or JSON)
- Support importing puzzles from common formats
- Export solved puzzles with solution steps
Hint System:
- Identify next logical move without giving away the answer
- Explain reasoning: "Row 5 can only have a 7 in column 3"
- Progressive hints: start with general area, get more specific
Statistics and Analytics:
- Track solving time and number of moves
- Identify which techniques were used to solve
- Generate difficulty rating for custom puzzles
- Solver should handle most puzzles in under 1 second
- Generator should create new puzzle in under 3 seconds
- Support undo/redo with efficient state management