My solutions to the Advent of Code 2023, written in 25 different programming languages.
- Day 01: C
- Day 02: COBOL
- Day 03: ALGOL 60
- Day 04: Nix
- Day 05: B (readme)
- Day 06: LLVM IR
- Day 07: Prolog
- Day 08: Objective-C
- Day 09: Curry
- Day 10: Java
- Day 11: Crystal
- Day 12: MoonScript
- Day 13: Vala
- Day 14: Go
- Day 15: Brainfuck, D
- Day 16: Zig
- Day 17: PHP
- Day 18: C++
- Day 19: Swift
- Day 20: Kotlin/Native
- Day 21: C#
- Day 22: Rust
- Day 23: Ruby
- Day 24: Haskell
- Day 25: Python
The programs are packaged with Nix, a functional package manager for Linux and macOS that focuses on reproducible builds. This makes it easy to build the programs, both locally and CI, without relying on system packages.
To build one of the days, cd
into the corresponding directory and build and/or run the Nix flake. For example, to run day 4, use the following commands:
cd day04
nix run . resources/input.txt
Every day is packaged up to take exactly one command-line argument, the input file, and usually includes the demo input from the exercise too.
Tip
The build environment can be added to the current PATH
using nix develop
. This is useful to manually run the compiler.
- Visualize the input with GraphViz (day 8, 20, 23, 25)
- Some puzzles are actually reverse-engineering exercises and rely on undocumented input constraints to be solved efficiently or even feasibly at all (day 8, 20, 23)
- Take the LCM to solve cycle alignment problems (day 8, 20)
- If there are offsets, use the CRT (like in previous years)
- Binary counters can elegantly be modeled as chains of flip flop (day 20)
- Cross products can be surprisingly useful to turn the most nonlinear-looking problems into linear equations (day 24)
My solutions to the previous challenges can be found here: