Pages

23/01/2026

[Source code] Determine to which subsquare does a cell belong to in a sudoku grid

Given a valid sudoku grid of size NxN, we might need to determine (for example for validation purposes), in which subsquare a specific cell belongs:

int squareIndex = (i / subsquareSize) * subsquareSize + (j / subsquareSize);

where subsquareSize = Math.sqrt(N);

No comments:

Post a Comment

With great power comes great responsibility