Skip to content

Commit

Permalink
Catch NoSolution - exact_cover now throws.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwg4 committed Nov 11, 2023
1 parent 81cfd6b commit 8d0d94a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion polyomino/problem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np

from exact_cover import get_exact_cover
from exact_cover.error import NoSolution

from .error import CantPlaceSinglePiece
from .solution import Solution
Expand Down Expand Up @@ -60,7 +61,10 @@ def make_problem(self):

def solve(self):
self.make_problem()
solution = get_exact_cover(self.array)
try:
solution = get_exact_cover(self.array)
except NoSolution:
return None
tiling = [self.key[s] for s in solution]
if tiling:
return Solution(tiling, self.board)
Expand Down

0 comments on commit 8d0d94a

Please sign in to comment.