r/adventofcode • • Dec 04 '20

SOLUTION MEGATHREAD -πŸŽ„- 2020 Day 04 Solutions -πŸŽ„-

Advent of Code 2020: Gettin' Crafty With It


--- Day 04: Passport Processing ---


Post your solution in this megathread. Include what language(s) your solution uses! If you need a refresher, the full posting rules are detailed in the wiki under How Do The Daily Megathreads Work?.

Reminder: Top-level posts in Solution Megathreads are for 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:12:55, megathread unlocked!

91 Upvotes

1.2k comments sorted by

View all comments

Show parent comment

1

u/b4ux1t3 Dec 04 '20

Without looking too deeply at your code, I might be able to point you to a bug:

For me, there was exactly one input passport that broke a naΓ―ve implementation of one of my rules, specifically the rule determining which eye color. I had a regex looking for, specifically, amb|blu|brn|gry|grn|hzl|oth. Since I was just looking for A match at all in the eye color, an input with these characters in this order in it, but not JUST those characters, would still match.

I don't think that is specifically your problem, but try to look for a rule somewhere that is even the slightest bit ambiguous in your code, and tighten it up. For me, all I had to do was add on the start (^) and end ($) of string anchors to my regex for the eye color.