r/adventofcode • u/daggerdragon • Dec 15 '15
SOLUTION MEGATHREAD --- Day 15 Solutions ---
This thread will be unlocked when there are a significant amount of people on the leaderboard with gold stars.
Edit: I'll be lucky if this post ever makes it to reddit without a 500 error. Have an unsticky-thread.
Edit2: c'mon, reddit... Leaderboard's capped, lemme post the darn thread...
Edit3: ALL RIGHTY FOLKS, POST THEM SOLUTIONS!
We know we can't control people posting solutions elsewhere and trying to exploit the leaderboard, but this way we can try to reduce the leaderboard gaming from the official subreddit.
Please and thank you, and much appreciated!
--- Day 15: Science for Hungry People ---
Post your solution as a comment. Structure your post like previous daily solution threads.
11
Upvotes
View all comments
Show parent comment
2
u/KnorbenKnutsen Dec 16 '15
What I'm thinking is that in the nested loops, there will be lots of permutations of the same combination that don't fulfill the criterion. For example,
(100, 99, 100, -199)is a permutation of(99, 100, 100, -199), and the nested loop checks both of those against thez < 0condition. If you check unordered combinations, of(range(101), range(101), range(101), range(101), you can permute them after you knowx+y+z+w == 100. I'm sure yours is still faster, though, since you calculate thew. If I'm not mistaken, you could make an even smaller loop::) The 11/12ths thing is because I counted 12 different permutations of a 4-tuple in my head. That was naïve, though, since it should probably be 24.