Advent of Code Day 4
Oscar te Giffel / June 03, 2021
• Last update: last Wednesday at 11:42 AM
For a long time, I always wanted to become better at puzzles with code. I see programmers like William Lin and Errichto and always envy them. So this year I thought, lets try it and start with the Advent of code.
Intro to the problem
The fourth day is about parsing "passports" and validating those passports. An example consists of multiple
key:value types. Each key stands for a specific value. Below are all keys and what they represent.
An example of what a passports looks like is:
To solve the first problem all the passports from the input had to fulfil all the the required fields except for the
cid field (because we all know that the passport is from the Northpole, duh...)
At first I thought about a simple approach with creating a simple parser that separated the lines and parsed those lines into a
Passport struct. The validation function could be as simple as this:
An other solution is somewhat difficult, slower but way more fun. We can create a parser in Go that validates all