Skip to content

Instantly share code, notes, and snippets.

@epitron
Created December 29, 2015 04:58
Show Gist options
  • Save epitron/c45fd2df312b035de40d to your computer and use it in GitHub Desktop.
Save epitron/c45fd2df312b035de40d to your computer and use it in GitHub Desktop.
# Solution by semi225599 https://www.reddit.com/r/adventofcode/comments/3y1s7f/day_24_solutions/cy9sqq2
from functools import reduce
from itertools import combinations
from operator import mul
wts = [int(x) for x in open("input.txt").read().split('\n')]
def day24(num_groups):
group_size = sum(wts) // num_groups
for i in range(len(wts)):
qes = [reduce(mul, c) for c in combinations(wts, i)
if sum(c) == group_size]
if qes:
return min(qes)
print(day24(3))
print(day24(4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment