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

Advent Of Code - Day 6

Advent Of Code - Day 6 Alright. This time, we are going to learn something that AOC does from time to time… Let’s break it down. Day 6 - Part 1 We start off really easy. We venture around in the sea, looking for nothing but trouble. We have our squid friend with us, whom we were telling everything about vents on the sea floor. Which happen to line up perfectly straight for some weird reason. ...

December 6, 2021 · 8 min · hannibal

Advent Of Code - Day 5

Advent of Code - Day 5 Alright. Today, we are going to learn something that will be useful to us in the coming days. Let’s see what we are dealing with. Edit: An interesting algorithm to read up on is Bresenham’s line algorithm. Day 5 - Part 1 We deal with vents today. The sea is a dangerous place after all. Fortunately for us, these vents line up perfectly so Santa can dodge them easily. We get a bunch of coordinates which form lines basically. The wording is pretty weird, says one end and the other. But these are just begin and end coordinates in a 2D grid. ...

December 5, 2021 · 5 min · hannibal

Advent Of Code - Day 4

Advent of Code - Day 4 Disclaimer: There is surely a better solution than this one. But I’m fairly okay with this one. And I wrote it, so… Okay, this day was a bit more complex now. But not in understanding what needed to be done, but implementing it. And then, part two of course. Day 4 - Part 1 We met a squid this day and decided to play a round of Bingo with it. Because, why not? Bingo is a simple game. You have several papers on which there are a couple numbers in a square. Someone draws a number, and you need to find that number on your boards, cards, slips, whatevers. Once you have marked 5 numbers in a row, or a column ( or, in the original game diagonal also goes ) you win. ...

December 4, 2021 · 5 min · hannibal

Advent Of Code - Day 3

Advent Of Code - Day 3 Here we go for day 3! This day was a tiny bit more complex. A lot of more things to read for sure! But all the more exciting! Let’s get to it! Day 3 - Part 1 We are dealing with binary numbers. At fist glance it can be daunting, but it’s actually not that complicated. We have to find two numbers. gamma rate and epsilon rate. To do that, we have to parse some binary numbers and then convert them to decimal. The two numbers can be found by looking for the most common bit at a given position in all of the numbers and the least common one at a given position in all of the given numbers. Better put, as we read on, find the bit that occurs most of the time and the one that occurs least of the time in all numbers and put them together. That’s your new number. ...

December 3, 2021 · 6 min · hannibal