Day 4! I was worried as I was reading the first problem yesterday that I would have to optimize for any rational slope. I'm thankful he decided to take it easier than that for Day 3.
The Puzzle
In today’s puzzle, we're just trying to get through airport security, which is jam-packed because, obviously, Santa's magic keeps the North Pole COVID-free. It's classified as a hum-bug. 🥁 Anyways. The passport scanner is broken and we're doing a good deed by "fixing" it. And by "fixing," we mean "hacking it to let us through but also mostly fixing it."
Y'all. We are THIS close to validating YAML and I am here for it.
The Leaderboards
As always, this is the spot where I’ll plug any leaderboard codes shared from the community.
Ryan's Leaderboard: 224198-25048a19
If you want to generate your own leaderboard and signal boost it a little bit, send it to me either in a DEV message or in a comment on one of these posts and I'll add it to the list above.
Yesterday’s Languages
Updated 03:06PM 12/12/2020 PST.
| Language | Count |
|---|---|
| Python | 8 |
| JavaScript | 3 |
| Rust | 2 |
| Haskell | 2 |
| C# | 1 |
| Raku | 1 |
| COBOL | 1 |
| PHP | 1 |
| Ruby | 1 |
| Elixir | 1 |
| Go | 1 |
| C | 1 |
Merry Coding!
Oldest comments (23)
My super gross rust impl. Messy regex. I am sure there are way better ways to parse according to white space.
Also, I sort of went half-way with a struct solution. Probably would have been better to either go all the way or not have custom types at all.
You're not alone in the ugly feeling. I had a particularly nasty bug that gave me one result too many in part two (realized I had a missing ^ and $ on the regex for
pid).I see a fair amount of similarities in approach, so I'm glad to see I'm in good company. :D
As always, on Github.
Again, more javascript. It's in a gist if you like that sort of thing.
Part 1 required far less code than part 2 😋
Here is a Haskell soloution for Day 4:
God damn, it was not that easy for me! To be honest, I'm not the best with both algorithms and Elixir, but... anyway AoC is a great chance to improve these skills. I've wasted time making stupid things with Regex. Facepalm.
There is my solution for the first step:
And the second step:
I hate problems like this:
Thank you so much for the clear and concise python, I'm new to python and thought this would be an excellent way to learn it. I figured this one out eventually and thought I would come here to see how someone else did it. I don't understand how yours doesn't throw a key error when trying to access dictionary keys that aren't there. I need to learn more about classes but I don't know why this works. If you could point me in the right direction I'd greatly appreciate it. Thank you again for the wonderful example
Plain forgot to break out of the comfort zone and use something other than javascript :|
I'll try C tomorrow
Here's today:
(added
checkas a way to see which field validator was broken when I failed part 2 the first time. It was a stupid typo in 'ecl')Not my finest work, I took advantage of the fact that some problems didn't arise in the test data. Then again, this isn't real life, it's a game and I got the stars. 😉
Part 2 here.
This was a long one, but I learned a ton about the
<string.h>library. I also incremented a macro by 1 and spent 3 hours chasing a segfault. So, all in all, I think it sounds like we all had similar days. There are also several edge cases that I'm pretty sure my code doesn't cover, BUT that doesn't matter because this is AoC and it's not wrong if you get the stars. Right? Right?Day4.h:
Day4.c:
Hi,
A lot of class for this one in order to limit each class responsability.
Full size here : Advent of Code - Day 4
I feel this reads as quite elegant in Ruby -- or at least my implementation of it.
Hoping on something more interesting to do for Day 5!