Fixed a bug in solve2
This commit is contained in:
parent
354e05db14
commit
a2fa29ab4b
1 changed files with 4 additions and 2 deletions
6
main.py
6
main.py
|
@ -70,8 +70,10 @@ def solve2(width, pattern, constraints=None):
|
||||||
maxgap = width - sum(pattern[1:]) - (len(pattern) - 1) - p
|
maxgap = width - sum(pattern[1:]) - (len(pattern) - 1) - p
|
||||||
|
|
||||||
for gap in range(maxgap + 1):
|
for gap in range(maxgap + 1):
|
||||||
e = expand_solution((gap,), gap + p + 1, (p,))
|
# constraint width
|
||||||
if not matches(e, constraints[:gap + p + 1]):
|
cw = (gap + p + 1) if len(pattern) > 1 else width
|
||||||
|
e = expand_solution((gap,), cw, (p,))
|
||||||
|
if not matches(e, constraints[:cw]):
|
||||||
continue
|
continue
|
||||||
if len(pattern) == 1:
|
if len(pattern) == 1:
|
||||||
yield (gap,)
|
yield (gap,)
|
||||||
|
|
Loading…
Reference in a new issue