Modulo Arithmetic
- One of the problems in the 9x9 Sudoku game-board is that the individual cells are labeled 0…80. (In programming one should use "zero-based" rather than "one-based" arrays).
- To address an individual cell you need to know its ROW and COL index
- For this you need to use "modulo arithmetic" and "integer division".
i=k\N (integer division)
j= k mod N (modulo arithmethic)
where:
N=9
k=cell [0…80]
i=ROW [0…8]
j=COL [0…8]
say:
k=10
i=10\9=1 (truncates to nearest integer)
j=10 mod 9=1 (truncates to nearest integer)
so:
ROW=1 (i.e. 2nd row)
COL=1 (i.e. 2nd column)