Advent of Code
Andrew van der Westhuizen
There exists a site called Advent of Code. It is a series of programming puzzles that are released daily during December. The puzzles are designed to be solved in any programming language. I have been participating to some degree since 2018. I have not always completed the puzzles, but I have always enjoyed the challenge. 2022 I decided to write about my experience.
This year we had to ensure the reindeer get to a grove. The grove has star fruit which provides enough magical energy to deliver the presents. We started an expedition to retrieve a minimum of fifty stars by December 25th.
Go solution The first day the Elves started hiking to the grove. They were carrying food with them. We had to find the largest basket of calories. My solution was written in go and we had to sum the input. It was a pleasure to write. I was done in under 10 minutes. Go is a great language.
Github copilot The second day a camp was to set up on the beach. The elves decided to play rock paper scissors to determine who would set up closest to the snacks. You get a encrypted strategy guide on how to win. Not being familiar with the go, I kept things basic. The solution was implemented in under 10 minutes. I have copilot to thank for that. Reflecting I realise how easy Java lends itself to over engineering.
Go solution The third day the rucksacks were packed for the jungle journy. The challenge was around packing efficiently. Using sets made the solution easy to write. However, I was lazy and instead of doing the math I just hardcoded ASCII to priority values. The second part was an order slower due to copying a slice whereas the first part was done in-place. I was not able to do the problem on day 3, so I did it on day 4 together with day 4's challenge. Both were completed together in under 30 min. I have no idea how the top guys finish so fast.
Go solution The forth day the camp was cleaned so that the ship could be unloaded. Elves were allocated areas to clean. Duplicate areas were assigned to groups. The challenge was to identify the duplication. The solution was unexpectedly easy. I learnt you don't need heavy data structures to solve problems.
SQL pivot The fifth day the unloaded crates needed to be repacked. The challenge was to execute the crane instructions. The hardest part was to read in the original state of the crates. From there it became a queueing problem. Github copilot is great if you know what the operations you want to apply are called. For instance, knowing what a pivot on a table does and naming a method with pivot, generated the correct code. However, I am not certain I would have had great success in the generation without that knowledge.
Go solution The sixth day we set out on foot. We were given a faulty communication device. The challenge was to identify packets. I have copilot to thank for most of the code. The generated code required some of my input, though minimal. The generated solution also made part two trivial. Copilot produced relatively bug-free code and definitely shaved about 30 minutes off the solution. The payoff is worth the cost/price/risk for me.