<commit_before>/*
    This problem can be solved by direct application of backtrack search.
*/

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include "io_util.h"
#include "string_util.h"

typedef std::vector<std::vector<int>> grid_type;

bool is_valid(grid_type &grid, int r, int c)
{
    // Check row.
    for (int _c = 0; _c < 9; _c++)
        if (_c != c && grid[r][_c] != 0 && grid[r][c] == grid[r][_c])
            return false;

    // Check column.
    for (int _r = 0; _r < 9; _r++)
        if (_r != r && grid[_r][c] != 0 && grid[r][c] == grid[_r][c])
            return false;

    // Check square.
    for (int _r = 3 * (r / 3); _r < 3 * (r / 3) + 3; _r++)
        for (int _c = 3 * (c / 3); _c < 3 * (c / 3) + 3; _c++)
            if (_r != r && _c != c && grid[_r][_c] != 0 && grid[_r][_c] == grid[r][c])
                return false;
<commit_msg>Enforce const correctness.<commit_after>/*
    This problem can be solved by direct application of backtrack search.
*/

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include "io_util.h"
#include "string_util.h"

typedef std::vector<std::vector<int>> grid_type;

bool is_valid(grid_type const &grid, int r, int c)
{
    // Check row.
    for (int _c = 0; _c < 9; _c++)
        if (_c != c && grid[r][_c] != 0 && grid[r][c] == grid[r][_c])
            return false;

    // Check column.
    for (int _r = 0; _r < 9; _r++)
        if (_r != r && grid[_r][c] != 0 && grid[r][c] == grid[_r][c])
            return false;

    // Check square.
    for (int _r = 3 * (r / 3); _r < 3 * (r / 3) + 3; _r++)
        for (int _c = 3 * (c / 3); _c < 3 * (c / 3) + 3; _c++)
            if (_r != r && _c != c && grid[_r][_c] != 0 && grid[_r][_c] == grid[r][c])
                return false;

{'fraction_non_alphanumeric': 0.20133111480865223, 'fraction_numerical': 0.018857459789240156, 'mean_word_length': 2.2622061482820977, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4339166', 'n_tokens_mistral': 732, 'n_tokens_neox': 686, 'n_words': 217}