r/adventofcode • • Dec 20 '15

SOLUTION MEGATHREAD --- Day 20 Solutions ---

This thread will be unlocked when there are a significant amount of people on the leaderboard with gold stars.

Here's hoping tonight's puzzle isn't as brutal as last night's, but just in case, I have Lord of the Dance Riverdance on TV and I'm wrapping my presents to kill time. :>

edit: Leaderboard capped, thread unlocked!

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 20: Infinite Elves and Infinite Houses ---

Post your solution as a comment. Structure your post like previous daily solution threads.

13 Upvotes

130 comments sorted by

View all comments

Show parent comment

0

u/willkill07 Dec 20 '15

I think I determined a lower-bound for search to be:

Part 1: k! where k! is maximized and strictly less than (input / 10)

Part 2: k! where k! is maximized and strictly less than (input / 11)

The trick for part2 is knowing ahead of time how many places are excluded because of the 50 house limit.

2

u/CryZe92 Dec 20 '15

That seems wrong. Let's assume we are searching for 70 presents. That's the fourth house. k! would be 6 though in your case (3! = 6 < 70 / 10)

1

u/[deleted] Dec 22 '15

As a lower bound, sadly far from optimal, one can take n that solves n(n-1)/2 = N/10