Advent of Code 2025 Day 4— Racket
Marketing Pitch and Impressions#
Mature: Racket is a mature and stable product. From the beginning, it has supported cross-platform graphical programming (Windows, macOS, Linux).
Practical: Racket includes a rich set of libraries, covering the full range from web server apps to mathematics and scientific simulation software.
Extensible: In Racket, programmers define their own loops with powerful macros. Indeed, these macros are so powerful that programmers make entire domain-specific languages as libraries. No tools, no Makefiles required.
Robust: Racket is the first language to support higher-order software contracts and safe gradual typing. Programmers can easily deploy these tools to harden their software.
Polished: Racket comes with support for major editors. The main bundle includes an innovative and extensible interactive development environment that has inspired other IDE projects.
The syntax relies on parenthesised S-expressions, which is likely the single most disliked feature of lisp family languages.
Visual Studio Code support is for Racket is excellent. Racket also has it’s own excellent IDE.
The Code#
Use of the λ character in place of the lambda symbol is cute and makes the
code more compact. I probably should have used let instead of define in
main too.
I parse all the input lines into a set of 2D points. This makes existence checking easier, and we don’t have to worry about grid boundaries as much.
For part 1, we just count points in the set that have less than 5 points in their neighbourhood (ie 4 + self).
For part 2, we iterate over the set, totalling and removing accessible rolls until there are no more accessible rolls.
| |
Install Racket and run#
# I installed via Homebrew
brew install --cask racket
# Official installer (Linux/macOS/Windows)
# https://download.racket-lang.org/
# Execute the code
racket d04.rkt