Sudoku solver using html, CSS and JavaScript
Write down the steps to solve before starting the coding
- input the board size (e.g: 3x3, 6x6, 9x9,...), initially just start with 9x9 board
- define an array to hold the confirmed number in each cells [array main]
- define an array to hold the possible numbers in each cells [array possibilities]
- Input the initial values of sudoku to be solved.
- Run fillPossibilities() once
- Define functions of each ways to find missing numbers:
- like function named find missing by checkEachRows():
traverse on each rows and check missing values, if a row missing only 1 value then fill that value by finding missing value from series e.g: for 9x9 sudoku, row =[1,null,3,4,5,6,7,8,9] the missing value is 2, so row =[1,2,3,4,5,6,7,8,9]
- function checkSingleCandidateInEachCells()
- function checkUniqueCandidateInEachCubes()
- function checkUniqueCandidateInEachRows()
- function checkUniqueCandidateInEachCols()
- like function named find missing by checkEachRows():
- loop on each method for finding missing numbers until cannot get a single number in every iteration
- loop on each method for finding
-
setValueToCell(value,rowIndx,colIndx):
to set value of main array -
displaySoduku():
to display (update dom) changes/latest sudoku data from main array