You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
555 B
Python

with open("input") as f:
jars = [int(n) for n in f.readlines()]
jars.sort(reverse=True)
def count_remaining_combinations(remaining_eggnog, remaining_jars):
if remaining_eggnog == 0:
return 1
if remaining_eggnog < 0:
return 0
if len(remaining_jars) == 0:
return 0
count = 0
for idx, jar in enumerate(remaining_jars):
count += count_remaining_combinations(
remaining_eggnog - jar, remaining_jars[idx + 1 :]
)
return count
print(count_remaining_combinations(150, jars))