Advent Of Code - Day 12 - Updated

Advent Of Code - Day 12 - Updated A comment from one of my readers prompted me to revise my solution on this trying to do part 2. The suggestions was that instead of using a struct as seen, use int and keep track of the count for small caves that way. I started to do that but got into various problems along the way when I got frustrated with my code, deleted the whole thing and begun again. But this lead me to a small, and better code than before which actually worked. ...

December 17, 2021 · 7 min · hannibal

Advent Of Code - Day 15

Advent Of Code - Day 15 Today, again, we open up Red Blob Games. It is a great source of information and descriptions. Especially, since this scenario is right up Red Blob’s ally. We need some weighted path finding. And Red Blob has a lovely post on that using the ever famous Dijkstra algorithm with a Priority Queue. Day 15 - Part 1 Let’s get to it. After refreshing my memory about priority queues, I remembered that there is a package and some sample code in Go which implements priority queues using the container/heap package here. ...

December 15, 2021 · 5 min · hannibal

Advent Of Code - Day 14

Advent Of Code - Day 14 Now we have to do some chemistry. Santa is pretty cool this way. They have a lot of skills mastered and read manuals like an expert. But this also means that manuals are always faulty. But Santa manages to work around these problems rather well. Day 14 - Part 1 So, by reading the description and looking at the outcome, that a string only after 5 iterations will be this big, begs the question if we should build a primitive solution for this. Well, yes, I think we should. Part 2 will most likely be about something like, okay, now do this, but longer. I suspect this will be like the lanterfish thing. But let’s do it anyways. ...

December 14, 2021 · 4 min · hannibal

Advent Of Code - Day 13

Advent Of Code - Day 13 This one was a lot of fun! Matrix folding was a bit fiddly but nothing too serious… Day13 - Part 1 By solving this part, I actually solved both parts. I had to butcher it to not solve both parts because I already dealt with folding both ways. First, we parse our input. We read out both the folding and the numbers first for easy handling later: ...

December 13, 2021 · 3 min · hannibal

Advent Of Code - Day 12

Advent Of Code - Day 12 EDIT: I revisited this problem and completely revised my solution to it: Day 12 Updated This one is a bit different from our little BFS walk the other day. I didn’t quite remember how DFS works, so I looked at the Wikipedia a bit. Then I remembered that I implemented this previously at some point in a later year. Disclaimer: I didn’t manage to finish part 2. I’m not sure what the bug is, but I moved on. When I’ll have the inspiration, I’ll figure it out. Unless, someone has an idea what’s going on. ...

December 12, 2021 · 3 min · hannibal

Advent Of Code - Day 11

Advent Of Code - Day 11 Today was an easier one again. It’s been a while since I last did some recursion anyway. At least, that’s how I solved this. I’m pretty sure my solution isn’t the most efficient one, but at least it’s working and it’s not horrible. Day 11 - Part 1 We have some number tracking to do again. This time, instead of fishes, we find ourself an bioluminescent octopus! This time, the rules are neatly outlined to us in a straight forward list. It sort of is like a Conway’s Game of Life scenario in which the current point affects its neighbours. ...

December 11, 2021 · 4 min · hannibal

Advent Of Code - Day 10

Advent Of Code - Day 10 Again, a bit of breathing time with an easier one. Although, it can be difficult, if you go down the path of trying to do it via recursion. Day 10 - Part 1 We have to match brackets. There can be a bit of a hassle if you go off on the wrong foot and try to implement it using recursion. But that works perfectly fine as well. But, there is a more elegant solution in which we just use a stack or try matching the last by updating it constantly. The stack is a heck of a lot easier. And considering part 2, it’s also more convenient. ...

December 10, 2021 · 5 min · hannibal

Advent Of Code - Day 9

Advent Of Code - Day 9 This one was an interesting one, and a step up from previous days. I used a BFS here and I have a fantastic link for the description, usage and appliance of BFS and others like A*. Pop over to Red Blog Games for all the good stuff. There are fantastic articles about all sorts of path finding and walking algorithms. Day 9 - Part 1 We start off again with something easy. Basically, just walk through a map, and find lowest values in it compared to neighbors of a cell. Here, we get to know a thing called direction calculation. In Go I have a list of points for that which will come in handy in other situations. But first, let’s parse our input. This time, I actually have a neat little trick on Go to create a slice of numbers from a slice of string numbers: ...

December 9, 2021 · 5 min · hannibal

Advent Of Code - Day 8

Advent Of Code - Day 8 If yesterday was a bit of a respite from adventuring, today was the boss fight for which we geared up for. The wall of text that hit us in the face, nearly depleted all of our HP. Let’s hope tomorrow brings some potions. Day 8 - Part 1 We start off relatively easy… We have to deal with old school number displays that use segments to display numbers. Luckily, for part one, all we are interested about is to find numbers in the output which are a definitive match against numbers which are displayed using the segmented display system. ...

December 8, 2021 · 4 min · hannibal

Advent Of Code - Day 7

Advent Of Code - Day 7 Day 7 - Part 1 Today we got a bit of respite with an easy one. Sort of like a Dark Souls bonfire. Let’s list our constraints. Today, we face a giant whale and some crabs in submarines which are less than effective. If they only move horizontally I have no idea how they’ve gotten as far as you. Maybe they pivot from time to time. Or they are indigenous to this region only. ...

December 7, 2021 · 4 min · hannibal