This project is a React web-app for solving Sudoku Puzzles backed by a NodeJS REST API. The Sudoku puzzles can be generated or manually entered. The Node API will attempt to solve the puzzles using a back-track algorithm provided a valid solution exists.
Backtracking is an algorithm for finding all (or some) of the solutions to a problem that incrementally builds candidates to the solution(s). As soon as it determines that a candidate cannot possibly lead to a valid solution, it abandons the candidate. Backtracking is all about choices and consequences.
Find row, col of an unassigned cell
If there is none, return true
For digits from 1 to 9
a) If there is no conflict for digit at row, col
assign digit to row, col and recursively try fill in rest of grid
b) If recursion successful, return true
c) Else, remove digit and try another
If all digits have been tried and nothing worked, return false
- The web-application can be visited here
- A guide on how to play Sudoku can be found here
- An excellent article on Sudoku Backtracking here
This project is a combination of code snippets and ideas from many sources. Thank you to the authors of these fine works for inspiration and code!
If you'd like to run this project yourself, you can follow the following steps:
- Clone the repository, or simply download the source code here
- Download and install NodeJS here
- Run the command
npm installin the same directory as the source code to install all the required packages - Run the command
npm startin the same directory as the source code to start both the API and Client
Mocha API integration tests.
npm test