r/adventofcode • • Dec 16 '20

SOLUTION MEGATHREAD -🎄- 2020 Day 16 Solutions -🎄-

Advent of Code 2020: Gettin' Crafty With It

  • 6 days remaining until the submission deadline on December 22 at 23:59 EST
  • Full details and rules are in the Submissions Megathread

--- Day 16: Ticket Translation ---


Post your code solution in this megathread.

Reminder: Top-level posts in Solution Megathreads are for code solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


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

EDIT: Global leaderboard gold cap reached at 00:21:03, megathread unlocked!

38 Upvotes

498 comments sorted by

View all comments

2

u/WilkoTom Dec 16 '20 edited Dec 16 '20

Python: Horrible, there are definitely some optimisations I can make in part 2:

https://github.com/wilkotom/AoC2020/blob/master/16/main.py

I was thrown for a while because my Part 1 answer was correct but it was letting a single invalid ticket with a 0 value through which threw me in part 2 - I had no columns which matched only a single rule. That led me to believe I might have to do possible evaluation against both possibilities being the first rule locked in place and work out which was the right one.

Fortunately the actual problem is much less evil.

1

u/UnicycleBloke Dec 16 '20

I made the same error. It cost me hours of frustration, and then I saw it immediately when I started explaining the code to a colleague.

1

u/kratsg Dec 16 '20

I had the same error as well since I was returning 0 when a ticket was valid... and .. sigh.