Skip to content

Instantly share code, notes, and snippets.

@dsasse07
Last active February 17, 2021 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsasse07/10869560d2e4c0538134733e7b24546f to your computer and use it in GitHub Desktop.
Save dsasse07/10869560d2e4c0538134733e7b24546f to your computer and use it in GitHub Desktop.
Sudoku safe placement row condition in JS
// puzzleArray is the game board being solved. A 9x9 matrix
// emptyCell = {rowIndex: INT , colIndex: INT } INT = coordinates of currently empty cell
// num = integer value 1-9 being tested
const rowSafe = (puzzleArray, emptyCell, num) => {
// -1 is return value of .find() if value not found
return puzzleArray[ emptyCell.rowIndex ].indexOf(num) == -1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment