Skip to content

Commit 314844a

Browse files
Update sol1.py
1 parent 8952756 commit 314844a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

project_euler/problem_164/sol1.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ def solve(
1818
previous-previous 'prev2' number, total sum of 'sum_max'.
1919
Pass around 'cache' to store/reuse intermediate results.
2020
21-
>>> solve(1, 0, 0, 9, True, {})
21+
>>> solve(digit=1, prev1=0, prev2=0, sum_max=9, first=True, cache={})
2222
9
23-
>>> solve(1, 0, 0, 9, False, {})
23+
>>> solve(digit=1, prev1=0, prev2=0, sum_max=9, first=False, cache={})
2424
10
2525
"""
2626
if digit == 0:
@@ -32,7 +32,7 @@ def solve(
3232
for v in range(sum_max - prev1 - prev2 + 1):
3333
if first and v == 0:
3434
continue
35-
comb += solve(digit - 1, v, prev1, sum_max, False, cache)
35+
comb += solve(digit=digit - 1, prev1=v, prev2=prev1, sum_max=sum_max, first=False, cache=cache)
3636
cache[cache_str] = comb
3737
return comb
3838

0 commit comments

Comments
 (0)