Advent of Code 2025 Day 7— Common Lisp
Marketing Pitch and Impressions#
Common Lisp is intended to meet these goals:
- Commonality
- Portability
- Consistency
- Expressiveness
- Compatibility
- Efficiency
- Power
- Stability
— Common Lisp The Language 2e, Guy L. Steele Jr. (abridged)
I’ve included the list of design goals from the introduction of Common Lisp The Language, Second Edition. There is a greater explanation of each point in the introduction, spanning several pages which I did not want to reproduce here.
While the Lisp family of languages has been around since the mid 1950s, Common Lisp did not come into existence until the early to mid 1980s, making either this solution or the C++ one the oldest language I’ve used this year.
Visual Studio Code support is good. Lots of folks prefer to use Emacs.
The Code#
Lisp and even Common Lisp some decades later, must have been wildly beyond their time. The functional focus with multi-paradigm pragmatism seem very modern. As mentioned in the Racket solution, some find the parenthesis-heavy syntax difficult to scan easily, and I can see why.
Again I compute the required values for part 1 and 2 in the same loop. The loop takes a snapshot of the current state at the beginning, and then scans across the current line looking for splitters. For part 1 we just keep track of the number of times a beam hits a splitter. For part 2, we need the total number of splitter duplications that didn’t end up off the edges of the manifold.
This, to me at least, seems like a pragmatic mix of functional style-looping and
shows how powerful the loop macro can be, combined with per-row stateful
mutation that means the solution runs quite quickly.
| |
Install SBCL and run#
SBCL seems to be the most widely supported open-source Common Lisp available, but others should work too.
# I installed via Homebrew
brew install sbcl
# Probably available in your package manager elsewhere
# sudo apt install sbcl
# Execute the code
sbcl --script d07.lsp