Skip to content

Commit

Permalink
WIP fix the bug in the sudoku.js file
Browse files Browse the repository at this point in the history
  • Loading branch information
Dor-sketch committed Jun 29, 2024
1 parent 333ad7f commit 785b6c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
24 changes: 9 additions & 15 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,14 @@ <h2>How to use the Interactive Board</h2>
</div>
</div>
</div>
<input id="input-board" type="text" placeholder="Enter board as one line...">
<button class="reset-button" onclick="resetBoard()">
<i class="fas fa-sync-alt"></i>
</button>
<button onclick="solveSudoku()" class="solve-button" aria-label="Solve Sudoku" id="solve-button">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polygon points="5 3 19 12 5 21 5 3"></polygon>
</svg>
</button>
<div class="actions">
<input id="input-board" type="text" placeholder="Enter board as one line...">
<button onclick="solveSudoku()" class="solve-button" aria-label="Solve Sudoku" id="solve-button">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polygon points="5 3 19 12 5 21 5 3"></polygon>
</svg>
</button>
</div>
</main>
<footer>
Expand Down Expand Up @@ -189,7 +187,7 @@ <h2>How to use the Interactive Board</h2>
}
});



function solveSudoku() {
const boardStr = readBoard();
Expand Down Expand Up @@ -231,10 +229,6 @@ <h2>How to use the Interactive Board</h2>
return true;
}

function resetBoard() {
/* if in the middle of solving or parsing, reset the board */
updateBoard('.................................................................................');
}

function isValidPlacement(boardStr, row, col, num) {
for (let i = 0; i < 9; i++) {
Expand Down
5 changes: 1 addition & 4 deletions docs/js/sudoku.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const sudokuBoard = document.getElementById('sudoku-board');
const initialBoard = '53..7....6..195....98....6.8...6...34..8.3..17...2...6.6....28....419..5....8..79';
const initialBoard = '.................................................................................';

// Initialize empty Sudoku board
const board = Array.from({ length: 9 }, () => Array(9).fill('.'));
Expand All @@ -10,7 +10,6 @@ for (let row = 0; row < 9; row++) {
// Add a class to the rowElement for the third and sixth rows
if (row === 2 || row === 5) {
rowElement.classList.add('section-border');
console.log('rowElement:', rowElement);
}
for (let col = 0; col < 9; col++) {
const cellElement = document.createElement('td');
Expand Down Expand Up @@ -261,5 +260,3 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
}


0 comments on commit 785b6c2

Please sign in to comment.