Dynamic-Programming : remove live code & console.log, leave examples as comments.

This commit is contained in:
Eric Lavault
2021-10-10 17:00:21 +02:00
parent 449ef45193
commit 29d2a84090
14 changed files with 95 additions and 124 deletions

View File

@ -1,14 +1,3 @@
const _board = [
['.', '9', '.', '.', '4', '2', '1', '3', '6'],
['.', '.', '.', '9', '6', '.', '4', '8', '5'],
['.', '.', '.', '5', '8', '1', '.', '.', '.'],
['.', '.', '4', '.', '.', '.', '.', '.', '.'],
['5', '1', '7', '2', '.', '.', '9', '.', '.'],
['6', '.', '2', '.', '.', '.', '3', '7', '.'],
['1', '.', '.', '8', '.', '4', '.', '2', '.'],
['7', '.', '6', '.', '.', '.', '8', '1', '.'],
['3', '.', '.', '.', '9', '.', '.', '.', '.']
]
const isValid = (board, row, col, k) => {
for (let i = 0; i < 9; i++) {
@ -43,8 +32,18 @@ const sudokuSolver = (data) => {
}
// testing
(() => {
if (sudokuSolver(_board)) {
console.log(_board)
}
})()
// const board = [
// ['.', '9', '.', '.', '4', '2', '1', '3', '6'],
// ['.', '.', '.', '9', '6', '.', '4', '8', '5'],
// ['.', '.', '.', '5', '8', '1', '.', '.', '.'],
// ['.', '.', '4', '.', '.', '.', '.', '.', '.'],
// ['5', '1', '7', '2', '.', '.', '9', '.', '.'],
// ['6', '.', '2', '.', '.', '.', '3', '7', '.'],
// ['1', '.', '.', '8', '.', '4', '.', '2', '.'],
// ['7', '.', '6', '.', '.', '.', '8', '1', '.'],
// ['3', '.', '.', '.', '9', '.', '.', '.', '.']
// ]
// sudokuSolver(board) // -> board updated by reference
export { sudokuSolver }