Racket solutions & explanations for the Advent of Code puzzles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
Matthew Butterick 14cae851fe fix deps 2 months ago
2016 Create README.md 3 years ago
2017 Create README.md 3 years ago
2018 d10 start 4 years ago
2019 d23 p2 (stuck) 3 years ago
2020 kw 2 years ago
2021 2021 solutions 9 months ago
.gitignore ignore 5 years ago
LICENSE.md Update and rename LICENSE to LICENSE.md 3 years ago
README.md Update README.md 1 year ago
aoc-racket.scrbl add index with per-function entries 7 years ago
day01-input.txt days 1-25 7 years ago
day01.rkt end the barbarism 3 years ago
day02-input.txt days 1-25 7 years ago
day02.rkt add index with per-function entries 7 years ago
day03-input.txt days 1-25 7 years ago
day03.rkt add index with per-function entries 7 years ago
day04-input.txt days 1-25 7 years ago
day04.rkt add index with per-function entries 7 years ago
day05-input.txt days 1-25 7 years ago
day05.rkt add index with per-function entries 7 years ago
day06-input.txt days 1-25 7 years ago
day06.rkt end the barbarism 3 years ago
day07-input.txt days 1-25 7 years ago
day07.rkt end the barbarism 3 years ago
day08-input.txt days 1-25 7 years ago
day08.rkt add index with per-function entries 7 years ago
day09-input.txt days 1-25 7 years ago
day09.rkt add index with per-function entries 7 years ago
day10-input.txt days 1-25 7 years ago
day10.rkt end the barbarism 3 years ago
day11-input.txt days 1-25 7 years ago
day11.rkt add index with per-function entries 7 years ago
day12-input.txt days 1-25 7 years ago
day12.rkt add index with per-function entries 7 years ago
day13-input.txt days 1-25 7 years ago
day13.rkt add index with per-function entries 7 years ago
day14-input.txt days 1-25 7 years ago
day14.rkt end the barbarism 3 years ago
day15-input.txt days 1-25 7 years ago
day15.rkt add index with per-function entries 7 years ago
day16-input-master-attrs.txt days 1-25 7 years ago
day16-input.txt days 1-25 7 years ago
day16.rkt end the barbarism 3 years ago
day17-input.txt days 1-25 7 years ago
day17.rkt end the barbarism 3 years ago
day18-input.txt days 1-25 7 years ago
day18.rkt add index with per-function entries 7 years ago
day19-input.txt days 1-25 7 years ago
day19.rkt end the barbarism 3 years ago
day20-input.txt days 1-25 7 years ago
day20.rkt end the barbarism 3 years ago
day21-input.txt days 1-25 7 years ago
day21.rkt add index with per-function entries 7 years ago
day22-input.txt day22 solution 6 years ago
day22.rkt missing line 6 years ago
day23-input.txt days 1-25 7 years ago
day23.rkt end the barbarism 3 years ago
day24-input.txt days 1-25 7 years ago
day24.rkt end the barbarism 3 years ago
day25-input.txt days 1-25 7 years ago
day25.rkt days 1-25 7 years ago
helper.rkt add index with per-function entries 7 years ago
info.rkt fix deps 2 months ago
main.rkt days 1-25 7 years ago

README.md

2015 edition

Racket solutions & explanations for the Advent of Code puzzles. Written in Racket's literate-programming dialect, scribble/lp2.

Install from the command line:

raco pkg install aoc-racket

Explanations will be installed automatically as part of the Scribble documentation.

Or just read the code and explanations online, right now.

2016 & onward editions

Solutions in the respective annual subdirectories.

MB’s Advent of Code tips

  • The problems are often designed around a particular computer-y abstraction. If you notice what the abstraction is, and then find the closest analog in Racket, the solution tends to come together quickly. Otherwise, you can spend a lot of time reinventing the wheel.

  • Complex numbers are a nice way of modeling two-dimensional positions.

  • Use lists whenever feasible, because there are many useful list functions in the Racket library that don’t have vector equivalents. In particular, these list functions are very useful, especially argmin and argmax.

  • Vectors are better than lists in situations where you need random access to members.

  • eq? is the fastest equality check, but it only works for symbols and fixnums (therefore, use more symbols and fixnums so you can use eq?!)

  • match is fantastic.

  • Association lists (= lists of pairs) are underrated. They’re compatible with all the usual list functions, of course, but also dictionary forms (like dict-ref and in-dict).

  • The graph library can be helpful for graph-based problems.

  • It’s good to know about sets and mutable pairs.

  • Also the fancier for iterators, like for/first and for/or.

  • let/ec is a way of jumping out of a deeply nested computation, akin to how return works in other languages.

My solutions

  • I try to write solutions that are succinct but not cryptic.

  • I don’t optimize for speed.

  • I like doing the Advent of Code problems because it forces me to use parts of Racket that I don’t ordinarily use. So I treat it as a chance to expand my awareness of the Racketverse.

  • I’m unlikely to finish every problem. Judging by past years, there is a point where the problems get sufficiently complex that I’d rather put that time into improving my other Racket projects 🤘

Project status

I only work on this project during puzzling season.