backtrack.py
This commit is contained in:
parent
ace1cfe04e
commit
2265cfbcb5
|
@ -47,15 +47,21 @@ def get_candidates(board: list, next_candidate_index: int) -> int:
|
|||
return all_candidates
|
||||
|
||||
def get_constraints(board: list, border: list, pos: int) -> list:
|
||||
pass
|
||||
board_dim = get_board_dim(board)
|
||||
col_idx = pos // board_dim
|
||||
row_idx = pos % board_dim
|
||||
constraints = []
|
||||
print(f'{board_dim=}, {pos=}, {col_idx=}, {row_idx=}')
|
||||
print(f'{border=}')
|
||||
# return constraints
|
||||
return True
|
||||
|
||||
def is_valid_state(board: list, border: list, next_candidate_index: int) -> bool:
|
||||
board_dim = get_board_dim(board)
|
||||
print_board(board, border)
|
||||
row = get_row(board, next_candidate_index)
|
||||
column = get_col(board, next_candidate_index)
|
||||
constraints = get_constraints(board, border, next_candidate_index)
|
||||
print(constraints, row, column)
|
||||
print(f'{constraints=}, {row=}, {column=}')
|
||||
return True
|
||||
|
||||
def print_board(board: list, border: list) -> None:
|
||||
|
@ -117,3 +123,4 @@ def main(*args, **kwargs) -> None:
|
|||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main('4 3 2 1 1 2 2 2 4 3 2 1 1 2 2 2'))
|
||||
# sys.exit(main(('0 ' * 81)[:-1]))
|
||||
|
|
Loading…
Reference in New Issue