def puzzle1() -> None: # INFO = "123456789123456789123456789123456789123456789123456789123456789123456789123456789" puzzle = "...6.1.....4...2...1.....6.1.......2....8....6.......4.7.....9...1...4.....1.2..3" texts = [(3, 1, 8), *[(x, 9) for x in range(1, 9)]] features: List[Feature] = [ ContainsTextFeature(i, text) for i, text in enumerate(texts, start=1) ] sudoku = Sudoku() sudoku.solve(puzzle, features=features)
def you_tuber() -> None: puzzle = '...........12986...3.....7..8.....2..1.....6..7.....4..9.....8...54823..........' features = [ LimitedKnightsMove(), *[ SameValueAsExactlyOneMateFeature((row, column)) for row in (4, 5, 6) for column in (4, 5, 6) ] ] sudoku = Sudoku() sudoku.solve(puzzle, features=features)
def magic_squares() -> None: puzzle = ('.' * 17) + "1" + ('.' * 54) + '.6.......' features = [ MagicSquareFeature((2, 6)), MagicSquareFeature((4, 2)), MagicSquareFeature((6, 8)), MagicSquareFeature((8, 4)), ] sudoku = Sudoku() sudoku.solve(puzzle, features=features)
def puzzle5() -> None: previo = '..7......3.....5......................3..8............15.............9....9......' puzzle = '......3...1...............72.........................2..................8........' diadem = SnakeFeature([(4, 2), (2, 1), (3, 3), (1, 4), (3, 5), (1, 6), (3, 7), (2, 9), (4, 8)]) thermometers = [ ThermometerFeature(name, [(row, column) for row in (9, 8, 7, 6, 5, 4)]) for column in (2, 4, 6, 8) for name in [f'Thermometer #{column // 2}'] ] features = [diadem, *thermometers] sudoku = Sudoku() sudoku.solve(merge(puzzle, previo), features=features)
def puzzle4() -> None: previo = '.......................1....4..................5...1.............................' puzzle = '...............5.....6.....' + (54 * '.') puzzle = merge(puzzle, previo) info1 = ((1, 2), (2, 2), (3, 3), (4, 4), (5, 4), (6, 4), (7, 4), (8, 4), (8, 3)) info2 = tuple((row, 10 - column) for (row, column) in info1) sudoku = Sudoku() sudoku.solve(puzzle, features=[ GermanSnakeFeature("Left", info1), GermanSnakeFeature("Right", info2), KnightsMoveFeature() ])
def puzzle3() -> None: previo = '....4........6.............8.....9..........6.........2..........................' puzzle = '..9...7...5.....3.7.4.....9.............5.............5.....8.1.3.....9...7...5..' evens = [(2, 3), (3, 2), (3, 3), (1, 4), (1, 5), (1, 6)] evens = evens + [(column, 10 - row) for row, column in evens] evens = evens + [(10 - row, 10 - column) for row, column in evens] features = [ SnakeFeature([(3, 6), (3, 5), (4, 4), (5, 4), (5, 5), (5, 6), (6, 6), (7, 5), (7, 4)]), LimitedValuesFeature(evens, (2, 4, 6, 8)), ] sudoku = Sudoku() sudoku.solve(merge(puzzle, previo), features=features)
def run_thermometer() -> None: thermometers = [[(2, 2), (1, 3), (1, 4), (1, 5), (2, 6)], [(2, 2), (3, 1), (4, 1), (5, 1), (6, 2)], [(2, 3), (2, 4), (2, 5), (3, 6), (3, 7), (4, 8)], [(2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (6, 8)], [(3, 2), (4, 3), (5, 4), (6, 5), (7, 6), (8, 7), (9, 7)], [(4, 2), (5, 2), (6, 3), (7, 4), (8, 4)], [(1, 7), (1, 8)], [(8, 8), (8, 9)], [(8, 2), (8, 3)]] puzzle = ' ' * 81 features = [ ThermometerFeature(f'Thermo {count}', thermometer) for count, thermometer in enumerate(thermometers, start=1) ] sudoku = Sudoku() sudoku.solve(puzzle, features=features) sudoku.draw_grid()
def puzzle2() -> None: previo: str = '...........................................5........3.............7..............' puzzle = '.9...16....................8............9............8....................16...8.' puzzle = merge(puzzle, previo) sudoku = Sudoku() sudoku.solve(puzzle, features=[MalvoloRingFeature()])