Hello Everybody ,
i have array of size 9x9 i want to write a function to Check each 3x3 box

Edited by Ahmed_62: ss

2 Years
Discussion Span
Last Post by Ahmed_62

This sounds like some sort of Sudoku type problem. Researching C++ source code for Sudoku should give you some samples to work with.


u r right .... i made function to check rows and another one one to check column and i cannot made one to check each box if u can help give me any hint xD


Starting with a 9X9 array(row,column)
One way is with another 9X9 array(square,cell), but this one arranged by each 3X3 square. Assuming the squares and the 3X3 cells can be indexed like:

0 1 2
3 4 5
6 7 8

Each row/column coordinate of the original array can be used to place each cell in the appropriate place in the new array.

The index of the square that a cell belongs in can be calculated with:

((column / 3) + (row / 3)) + ((row / 3) * 2)

The index of a cell inside the square can be calculated with:

((column  % 3) + (row % 3)) + ((row % 3) * 2)

Edited by tinstaafl

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.