(int row, int col) fromIndex(int index) { int row = index ~/ _cols; // Integer division to get the row (from square) int col = index % _cols; // Modulo to get the column (to square) return (row, col); }