Skip to content

avdvh/Sudoku

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sudoku Solver

This is a Sudoku Solver built using HTML, CSS, and JavaScript. The application provides a clean, intuitive, and interactive interface to solve and reset Sudoku puzzles. It allows users to enter values, validate inputs, and see the solution generated through a backtracking algorithm.

Features

  • Sudoku Grid: The 9x9 grid is dynamically created, and users can enter values (numbers 1-9) into the cells.
  • Input Validation: Ensures that only valid numbers (1-9) are entered, and checks for duplicates in the rows, columns, and 3x3 subgrids.
  • Solve Puzzle: Solves the Sudoku puzzle using a backtracking algorithm.
  • Reset Board: Clears the current input and solution to start fresh.
  • Error Messages: Displays error messages for invalid inputs or unsolvable grids.

UI Design

  • The design features a dark theme with bright, contrasting colors for input validation.
  • User-entered numbers are highlighted with an orange color, while the numbers generated by the algorithm appear in white.
  • Error messages are shown in red to easily grab attention when an invalid input is detected.
  • The layout is responsive and adapts to different screen sizes and devices, ensuring a smooth experience on both mobile and desktop.

How to Use

  1. Enter a Sudoku puzzle by clicking on the cells and typing numbers (1-9).
  2. If any invalid input is detected (such as a duplicate or a number outside the valid range), an error message will appear.
  3. Press the Solve button to find the solution for the puzzle.
  4. Press the Reset button to clear the grid and start a new puzzle.

Screenshots

SUDOKU SOLVER

Algorithm

The puzzle is solved using a backtracking algorithm, which tries all possible values (1-9) for empty cells, checks if they’re valid based on Sudoku rules, and continues until the puzzle is solved or determined to be unsolvable.

Backtracking steps:

  • Find an empty cell.
  • Try placing a number (1-9) and check if it’s valid.
  • If valid, move to the next empty cell.
  • If an invalid placement is encountered, backtrack and try the next possible number.

Key Concepts

  • Input Validation: Ensures that user inputs conform to Sudoku’s constraints, such as avoiding duplicate numbers in rows, columns, and 3x3 grids.
  • Responsive Design: The layout adapts to mobile and desktop screens for a seamless experience across devices.

Made with ❤️ by Anmol