---
title: Things I Learnt During Advent of Code 2023
publishedDate: 2023-12-31
tags:
    - projects
---
I've been doing Advent of Code every December since 2020, which means that now I've done four years worth of these challenges, culminating in AoC 2023. As with every year, AoC 2023 was packed to the brim with interesting, educational and (mostly) rewarding problems and, as a first for this year, I'm going to run through some of the interesting things I've learnt.

This post will contain spoilers!

# Simpler is Better

This point is partially a little bit meta and partially a spiritual predecessor to the rest of this post.

For every year I've done AoC, I've used a challenge runner in order to test and run my challenges. They typically run, time and output the answers generated by my solutions, and if there are tests, check that those tests pass. For the past two years, I've used this massive, complex (and disastrous) runner that requires any challenge solution to speak a JSON protocol with the runner over stdin/stdout, had to time itself running challenges and had to not output anything that could *look* like JSON when debugging. It also meant that I couldn't easily manually run challenges outside of the runner. It sucked.

So this year, I decided to ~~revise~~ delete my existing runner and [rewrote it as 400 lines of Python](https://github.com/codemicro/adventOfCode/blob/4f7b3f4da6f2cb494c912363fe77d22353410119/aoc). It's super simple, does everything the old one could *and* talks via stdin, stdout and stderr so I can use it with ease . Genuinely very glad I decided to throw away all my hours of old work.

This isn't the only thing that "simpler is better" applies to, though. I'm also very prone to overcomplicating the way I represent state within my solutions. I like lots of fancy types and "clever" data structures, which definitely bit me this year. Having a look at the solution megathreads after I've finished my solution and seeing how I unknowingly made my life so so much harder than it needed to be be pained me. Simpler is better!

# Brute Force is Ok Too

# Python has `foldr`, I'm Just An Idiot

# How `functools.cmp_to_key` Works

# Type Hint Updates in Python

# The Shoelace Algorithm and Pick's Theorem

# Sometimes State Machines are Cool

# Using Intelligent Data Structures

# Representing Complex States with Djikstra's (bonus: I Can't Code)

# Z3 Solver
