Created
October 25, 2020 21:00
-
-
Save leynier/ec93b9b4728bd559f8c8504c9931ad6c to your computer and use it in GitHub Desktop.
Pseudo code of solve of Hidato
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solve(table, step, limit): | |
if step == limit + 1: | |
return [table] | |
else: | |
return [ | |
item | |
for new_table in step_matrix(table, step) | |
for item in solve(new_table, step + 1, limit) | |
] | |
def step_matrix(table, step): | |
if cell_in_table(step, table): | |
if get_cell_value(get_cell(table, step)) == 1 or is_adyacents(get_cell(table, step), get_cell(table, step - 1)): | |
return [table] | |
else: | |
return [] | |
else: | |
return [ | |
update_cell_in_table(table, update_value_in_cell(step, cell)) | |
for cell in get_adyacents(table, get_cell(table, step - 1)) | |
if get_cell_value(cell) == 0 | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment