From ade4ec6a8393c5173f1d6202131f4888384c861c Mon Sep 17 00:00:00 2001 From: Marianne Chevrot Date: Sun, 17 May 2020 11:22:23 +0200 Subject: separate solution generation and its display --- solver.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'solver.py') diff --git a/solver.py b/solver.py index b42cbc4..d10d347 100755 --- a/solver.py +++ b/solver.py @@ -354,18 +354,13 @@ def print_score_over(node, target_score): print_score_over(child, target_score) -def search_all_solution(args, kanagrid, target_score, max_actions): +def search_all_solution(kanagrid, target_score, max_actions): grids = {} generate_all_possible_grids(kanagrid, grids=grids, max_actions=max_actions) for grid in grids.values(): grid.update_score() if grid.score >= target_score and grid.myst_count == 0: - print("="*80) - if args['-p']: - print(repr_grid_with_parents(grid)) - else: - print(grid) - return grid + yield grid def main(): @@ -385,7 +380,12 @@ def main(): if args['--print']: return - search_all_solution(args, kanagrid, target_score, max_actions) + for grid in search_all_solution(kanagrid, target_score, max_actions): + print("="*80) + if args['-p']: + print(repr_grid_with_parents(grid)) + else: + print(grid) if __name__ == '__main__': -- cgit v1.2.3