Esempio n. 1
0
void test_cols_are_different() {
    cout << "Begin testing cols are different" << endl;
    
    int board[MAX_SIZE][MAX_SIZE];
    
    // test case 1
    string test_board_1[] = {"XX--",
                             "OO--",
                             "OO--",
                             "XX--"};
    int size_1 = 4;
    read_board_from_string(board, test_board_1, size_1);
    cout << cols_are_different(board, size_1, 0, 1) << endl;
    
    // test case 2
    string test_board_2[] = {"XX--",
                             "OX--",
                             "OO--",
                             "XX--"};
    int size_2 = 4;
    read_board_from_string(board, test_board_2, size_2);
    cout << cols_are_different(board, size_2, 0, 1) << endl;
    
    // test case 3
    string test_board_3[] = {"XX--",
                             "OO--",
                             "-O--",
                             "XX--"};
    int size_3 = 4;
    read_board_from_string(board, test_board_3, size_3);
    cout << cols_are_different(board, size_3, 0, 1) << endl;
    
    // test case 4
    string test_board_4[] = {"XX--",
                             "OO--",
                             "-O--",
                             "XX--"};
    int size_4 = 4;
    read_board_from_string(board, test_board_4, size_4);
    cout << cols_are_different(board, size_4, 2, 3) << endl;
    
    // test case 5
    string test_board_5[] = {"XX--",
                             "OO--",
                             "----",
                             "XX--"};
    int size_5 = 4;
    read_board_from_string(board, test_board_5, size_5);
    cout << cols_are_different(board, size_5, 0, 1) << endl;
    
    cout << "End testing cols are different" << endl;
}
Esempio n. 2
0
bool board_has_no_duplicates(const int board[MAX_SIZE][MAX_SIZE], int size) {
    for (int x = 0; x < size; x++) {
        for (int y = x + 1; y < size; y++) {
            if (!rows_are_different(board, size, x, y)) {
                return false;
            }
            else if (!cols_are_different(board, size, x, y)) {
                return false;
            }
        }
    }

    return true;
}