27 lines
606 B
Python
27 lines
606 B
Python
from itertools import combinations
|
|
data = open(0).read().strip()
|
|
|
|
cons = list(map(int, data.splitlines()))
|
|
part_1 = False
|
|
if part_1:
|
|
def count(n, cons):
|
|
if n == 0:
|
|
return 1
|
|
elif len(cons) == 0:
|
|
return 0
|
|
r = 0
|
|
first = cons[0]
|
|
r += count(n - first, cons[1:])
|
|
r += count(n, cons[1:])
|
|
return r
|
|
print(count(150, cons))
|
|
else:
|
|
r = 0
|
|
for i in range(1, len(cons) + 1):
|
|
for c in combinations(cons, i):
|
|
if sum(c) == 150:
|
|
r += 1
|
|
if r > 0:
|
|
print(i)
|
|
break
|