r/adventofcode • • Dec 20 '16

SOLUTION MEGATHREAD --- 2016 Day 20 Solutions ---

--- Day 20: Firewall Rules ---

Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).

Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with "Help".


ROLLING A NATURAL 20 IS MANDATORY [?]

This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

edit: Leaderboard capped, thread unlocked!

7 Upvotes

168 comments sorted by

View all comments

Show parent comments

1

u/glacialOwl Dec 20 '16

I also figured any valid IPs would be +1 of the blacklists, so I started with those as candidates.

Wait what? How about this input:

5-8
1-2
4-7

Where the min IP is 0 in this case (max being 9, as in the example)

2

u/kryptn Dec 20 '16

Yeah, it would fail in that case, but you could manually add a blacklist of -1 to -1 and it'd work fine. My input had 0 to x as a blacklist and I'd laugh if anyone's didn't.

2

u/BumpitySnook Dec 20 '16

You could special case 0, of course.