Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Sudoku Project Instructions

This project is a Flask-based Sudoku application.

Code Style:

- Prefer readability over clever implementations.
- Use modern Python features and type hints where appropriate.
- Keep functions small and focused.
- Avoid duplicated code.
- Follow consistent naming conventions.
- Add comments only when they improve understanding.

Architecture:

- Separate game logic from Flask routes.
- Keep UI, business logic, and persistence concerns isolated.
- Prefer reusable helper functions and classes.

Sudoku Requirements:

- Every generated puzzle must have exactly one solution.
- Support Easy, Medium, and Hard difficulties.
- Prefilled cells must remain locked.
- Invalid moves should provide immediate visual feedback.
- Hint cells should become locked after being filled.
- Maintain a Top 10 leaderboard.
- Persist leaderboard data between sessions.

Frontend Requirements:

- Mobile responsive layout.
- Support light and dark themes.
- Alternate colors for 3x3 Sudoku regions.
- Maintain accessibility and readability.

Testing:

- Use pytest.
- Preserve existing behavior during refactoring.
- Add tests for Sudoku generation and validation logic.=[]p
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python-envs.pythonProjects": []
}
Binary file added Screenshot 2026-09-04 at 12.17.37 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshot 2026-09-04 at 12.17.52 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshot 2026-09-04 at 12.41.08 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshot 2026-09-04 at 12.44.25 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshot 2026-09-04 at 12.44.39 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshot 2026-09-04 at 4.02.25 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshot 2026-09-04 at 4.02.33 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshot 2026-09-04 at 4.11.23 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added starter/__pycache__/app.cpython-313.pyc
Binary file not shown.
Binary file added starter/__pycache__/sudoku_logic.cpython-313.pyc
Binary file not shown.
29 changes: 28 additions & 1 deletion starter/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,38 @@ def index():

@app.route('/new')
def new_game():
clues = int(request.args.get('clues', 35))
difficulty = request.args.get('difficulty', 'medium')

try:
clues = sudoku_logic.clue_count_for_difficulty(difficulty)
except ValueError as error:
return jsonify({'error': str(error)}), 400

puzzle, solution = sudoku_logic.generate_puzzle(clues)
CURRENT['puzzle'] = puzzle
CURRENT['solution'] = solution

return jsonify({'puzzle': puzzle})
@app.route('/hint', methods=['POST'])
def get_hint():
data = request.json or {}
board = data.get('board')
puzzle = CURRENT.get('puzzle')
solution = CURRENT.get('solution')

if puzzle is None or solution is None:
return jsonify({'error': 'No game in progress'}), 400

for row in range(sudoku_logic.SIZE):
for col in range(sudoku_logic.SIZE):
if puzzle[row][col] == sudoku_logic.EMPTY and board[row][col] == sudoku_logic.EMPTY:
return jsonify({
'row': row,
'col': col,
'value': solution[row][col],
})

return jsonify({'error': 'No empty cells available'}), 400

@app.route('/check', methods=['POST'])
def check_solution():
Expand Down
1 change: 1 addition & 0 deletions starter/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Flask>=2.0
pytest>=8.0
Loading