Esempio n. 1
0
def get_cell_value(puzzle, row_id, column_id):
    if random.random() < 0.2:
        return random.choice(sudoku.DIGITS)

    cells = sudoku.get_column(puzzle, column_id) if random.random() > 0.5 else sudoku.get_row(puzzle, row_id)
    values = sudoku.get_remaining_values(cells)

    return random.choice(values) if len(values) > 0 else random.choice(sudoku.DIGITS)
def test_get_column():
    assert sudoku.get_column(grid_elements, 3) == [
        (1, 3),
        (2, 3),
        (3, 3),
        (4, 3),
        (5, 3),
        (6, 3),
        (7, 3),
        (8, 3),
        (9, 3),
    ]
 def test_get_column(self):
     self.assertEqual(sudoku.get_column(grid_elements, 3),
                      [(1,3), (2,3), (3,3), (4,3), (5,3),
                       (6,3), (7,3), (8,3), (9,3)])
Esempio n. 4
0
def test_get_column():
    assert sudoku.get_column(grid_elements, 3) == \
           [(1,3), (2,3), (3,3), (4,3), (5,3), (6,3), (7,3), (8,3), (9,3)]
 def test_column_extraction(self):
     self.assertEqual(sudoku.get_column(sudoku_problems['easy1'],0), [0,0,1,5,8,0,3,0,0])