Created
December 29, 2015 04:58
-
-
Save epitron/c45fd2df312b035de40d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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