Recursive solution to Sudoku generator

后端 未结 6 930
青春惊慌失措
青春惊慌失措 2020-12-19 05:14

I\'m trying to code an algorithm that creates a legal Sudoku board in either Java or Javascript. Neither work, and I\'m not entirely sure why.

Essentially, the prob

6条回答
  •  一整个雨季
    2020-12-19 06:03

    In Java array indexes are zero-based. In nextBoard you loop over 1..9 for i and use it as an index into toCheck which will skip the first element at index 0 and go past the end of the array. This will throw ArrayIndexOutOfBoundsException if the line containing toCheck[i] is reached with i equal to 9.

提交回复
热议问题