Skip to content

saurabhkumar005/Sudoku_solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🧩 Sudoku Solver & Visualizer

An interactive, fully responsive web application that generates, solves, and visualizes Sudoku puzzles. This project bridges the gap between Competitive Programming (CP) logic and Frontend Development, demonstrating how complex algorithms like Backtracking can be applied in a practical user interface.

🚀 Live Demo: sudokusolverbysk.vercel.app


✨ Features

🎮 Gameplay & Generation

  • Sudoku Generation: Creates unique, solvable puzzles with three distinct difficulty levels:
    • Easy: 30 cells removed.
    • Medium: 40 cells removed.
    • Hard: 50 cells removed.
  • Custom Input: Clear the board and enter your own puzzles to solve them instantly.
  • Intelligent Hint System: Uses the solver algorithm to find the correct value for the most constrained empty cell.

🧠 Advanced Logic

  • Step-by-Step Visualization: Watch the backtracking algorithm "think" in real-time with customizable delays and color-coded cell states (Trying vs. Backtracking).
  • MRV Heuristic: Optimized search space using the Minimum Remaining Values technique.

🛠️ Utilities

  • Game Persistence: Save your current progress and hint count to localStorage and resume later.
  • Performance Metrics: Built-in timer and score tracker to gamify the experience.
  • Fully Responsive: Optimized UI for both Desktop and Mobile devices.

🧠 Algorithmic Deep-Dive

The Solver (Backtracking + MRV)

The core engine uses a Depth-First Search (DFS) based backtracking algorithm. To optimize the search space, it employs the Minimum Remaining Values (MRV) heuristic:

  1. Find the Most Constrained Cell: Instead of picking the first empty cell, the algorithm finds the cell with the fewest valid candidates.
  2. Pruning: If a cell has zero candidates, the algorithm "fails fast" and backtracks immediately.
  3. Randomization: During generation, candidate numbers (1–9) are shuffled to ensure a unique board every time.

Time Complexity

Function Complexity Description
Solver O(9^M) M = number of empty cells
Heuristic (MRV) O(N^4) Can be optimized to O(N^3)
Validation O(N^3) Can be optimized to O(N^2)

🛠️ Tech Stack

  • Structure: HTML5
  • Styling: Tailwind CSS & Custom CSS3
  • Language: JavaScript (ES6+)
  • Storage: LocalStorage API

📂 Project Structure

├── index.html      # Structure & UI Components
├── index.css       # Custom animations & Media Queries
└── function.js     # Solver logic, Heuristics & DOM Manipulation


🔧 Installation & Usage

  1. Clone the repository:
git clone [https://github.com/yourusername/sudoku-solver.git](https://github.com/yourusername/sudoku-solver.git)
  1. Open the project: Simply open index.html in any modern web browser. No build steps, installations, or dependencies required.

🤝 How to Contribute

This project is completely open-source and I welcome contributions! If you want to improve the algorithm, or to improve the UI, or fix a bug, or any new feature, feel free to jump in.

  1. Fork the repository.
  2. Clone your fork: git clone https://github.com/yourusername/sudoku-solver.git
  3. Create a branch: git checkout -b feature/your-feature-name
  4. Commit your changes: git commit -m "Add some feature"
  5. Push to the branch: git push origin feature/your-feature-name
  6. Open a Pull Request!

📄 License

This project is licensed under the MIT License. You are free to use, modify, and distribute this software as you see fit. See the LICENSE file for more details.


👤 Author

Saurabh Kumar


This project was developed as part of a 6-week summer training in Competitive Programming, focusing on bridging the gap between algorithmic theory and practical software implementation.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors