Thanks to visit codestin.com
Credit goes to github.com

Skip to content

silverasphodel17/sudoku

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sudoku Game

A feature-rich, interactive Sudoku game built with vanilla HTML, CSS, and JavaScript. Play classic Sudoku puzzles with multiple difficulty levels, hints, and a built-in timer.

Features

🎮 Game Modes

  • Easy: 35 cells removed, includes error checking and real-time validation
  • Medium: 45 cells removed (default)
  • Hard: 55 cells removed

⏱️ Built-in Timer

  • Automatic timer that starts when you begin playing
  • Displays elapsed time in MM:SS format
  • Resets with each new game

💡 Smart Hint System

  • Toggle hints on/off to show possible valid numbers for empty cells
  • Contextual feedback in Easy mode (correct/incorrect number validation)
  • Hints automatically clear when you enter a number

🎯 Interactive Controls

  • Keyboard Navigation: Use arrow keys to move between cells
  • Number Input: Press 1-9 to enter numbers
  • Clear Cells: Press Backspace, Delete, or 0 to clear
  • Mouse Support: Click any cell to select it

✅ Solution Features

  • Check Solution: Validate your current progress
  • Show Solution: Instantly reveal the complete solution
  • New Game: Generate fresh puzzles anytime

How to Play

  1. Open the Game: Open sudoku.html in your web browser
  2. Select Difficulty: Choose Easy, Medium, or Hard from the dropdown
  3. Fill the Grid: Click cells and enter numbers 1-9
  4. Use Hints: Click the "Hint" button to see possible numbers for empty cells
  5. Navigation: Use arrow keys or mouse to move between cells
  6. Check Progress: Use "Check Solution" to validate your current state
  7. Win: Complete the puzzle with all correct numbers!

Game Rules

Fill the 9×9 grid so that every row, column, and 3×3 box contains the digits 1-9 exactly once.

Technical Implementation

Algorithm Highlights

  • Puzzle Generation: Uses recursive backtracking to create valid, solvable Sudoku puzzles
  • Real-time Validation: Checks row, column, and 3×3 box constraints
  • Smart Hint System: Calculates all possible valid numbers for any cell
  • Adaptive Difficulty: Removes different numbers of cells based on selected difficulty

Code Structure

  • Object-Oriented Design: Clean SudokuGame class with separated concerns
  • Event-Driven: Responsive keyboard and mouse interactions
  • State Management: Maintains separate board, solution, and hint states
  • Efficient Algorithms: Fisher-Yates shuffle for randomization, Set data structures for optimization

Browser Compatibility

Works in all modern browsers with JavaScript enabled. No external dependencies required.

Files

  • sudoku.html - Main game interface and structure
  • sudoku.css - Styling and responsive layout
  • sudoku.js - Core game logic and algorithms

Getting Started

  1. Clone or download the project files
  2. Open sudoku.html in any modern web browser
  3. Start playing immediately - no installation required!

Customization

The game is easily customizable:

  • Modify difficulty levels in the newGame() method
  • Adjust styling in sudoku.css
  • Add new features by extending the SudokuGame class

Enjoy playing Sudoku! 🧩

About

Sudoku, close to the way I play it on paper.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published