I tried everything on the online editor but still get the error. But when I do this on VSCode on my machine, it works fine. I'm confused and can't submit the code without finding the bug. I don't know where to look anymore. I wish I had another pair of eyes looking at this for me. I am truely thankful.
//puzzle
let puzzle = [
[8, 9, 5, 7, 4, 2, 1, 3, 6],
[2, 7, 1, 9, 6, 3, 4, 8, 5],
[4, 6, 3, 5, 8, 1, 7, 9, 2],
[9, 3, 4, 6, 1, 7, 2, 5, 8],
[5, 1, 7, 2, 3, 8, 9, 6, 4],
[6, 8, 2, 4, 5, 9, 3, 7, 1],
[1, 5, 9, 8, 7, 4, 6, 2, 3],
[7, 4, 6, 3, 2, 5, 8, 1, 9],
[3, 2, 8, 1, 9, 6, 5, 4, 7],
];
//puzzle 2
let puzzleTwo = [
[8, 9, 5, 7, 4, 2, 1, 3, 6],
[8, 7, 1, 9, 6, 3, 4, 8, 5],
[4, 6, 3, 5, 8, 1, 7, 9, 2],
[9, 3, 4, 6, 1, 7, 2, 5, 8],
[5, 1, 7, 2, 3, 8, 9, 6, 4],
[6, 8, 2, 4, 5, 9, 3, 7, 1],
[1, 5, 9, 8, 7, 4, 6, 2, 3],
[7, 4, 6, 3, 2, 5, 8, 1, 9],
[3, 2, 8, 1, 9, 6, 5, 4, 7],
];
//DO NOT EDIT ABOVE
function getRow(puzzle, row) {
let array = [];
for (let i = 0; i
This is the error message I received. When the sudoku is invalid, the prompt asks me to return false. As you can see, it does return false for invalid puzzles, but not for all invalid puzzles.
FAIL ./index.test.js
sudoku sudokuIsValid
✓ returns false for an invalid puzzle (2 ms)
✕ returns false for other invalid puzzles (2 ms)
● sudoku sudokuIsValid › returns false for other invalid puzzles
expect(received).toBe(expected) // Object.is equality
Expected: false
Received: true
21 | ];
22 | let result = sudoku.sudokuIsValid(puzzle)
> 23 | expect(result).toBe(false);
| ^
24 | });
25 |
26 | });
at Object. (index.test.js:23:20) 1 answers
Your includes1To9() only checks if adjacent elements are the same:
function includes1To9(arr) {
let prev = arr[0];
for (let i = 1; i
Hot tools Tags
Hot Questions
Popular tool
vc9-vc14 (32+64 bit) runtime library collection (link below)
Download the collection of runtime libraries required for phpStudy installation
VC9 32-bit
VC9 32-bit phpstudy integrated installation environment runtime library
PHP programmer toolbox full version
Programmer Toolbox v1.0 PHP Integrated Environment
VC11 32-bit
VC11 32-bit phpstudy integrated installation environment runtime library
SublimeText3 Chinese version
Chinese version, very easy to use
Hot Topics
20417
7
13577
4






