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 3dbf136103 d23 p2 (stuck) 3 years ago
01.rkt 2019 d01 & d02 3 years ago
01.rktd 2019 d01 & d02 3 years ago
02.rkt 2019 d01 & d02 3 years ago
02.rktd 2019 d01 & d02 3 years ago
03.rkt simplify loop 3 years ago
03.rktd d03 3 years ago
04.rkt use integers 3 years ago
04.rktd d04 3 years ago
05.rkt simplify 3 years ago
05.rktd d05 3 years ago
06.rkt d06 alternate solution 3 years ago
06.rktd d06 3 years ago
07-gen.rkt d07 alternate solution with generators 3 years ago
07.rkt d07 pt2 3 years ago
07.rktd d07 pt1 3 years ago
08.rkt d08 3 years ago
08.rktd d08 3 years ago
09.rkt tidy 3 years ago
09.rktd d09 (stuck) 3 years ago
10.rkt rectangularity 3 years ago
10.rktd d10 p1 3 years ago
11.rkt d11 3 years ago
11.rktd d11 3 years ago
12.rkt d12 p2 3 years ago
12.rktd d12 p1 3 years ago
13.rkt d13 p2 3 years ago
13.rktd d13 p1 3 years ago
14.rkt d14 p1 3 years ago
14input.rkt d14 p1 3 years ago
14test.rkt d14 p1 3 years ago
15.rkt d15 p2 3 years ago
15.rktd d15 p1 (stuck) 3 years ago
16.rkt ref 3 years ago
16.rktd correct numbering 3 years ago
17.rkt d17 p1 3 years ago
17.rktd d17 p1 3 years ago
19.rkt d19 3 years ago
19.rktd d19 3 years ago
20.rkt d20 p1 3 years ago
20.rktd d20 p1 3 years ago
22.rkt d22 p2 (stuck) 3 years ago
22.rktd d22 p1 3 years ago
23.rkt d23 p2 (stuck) 3 years ago
23.rktd d23 p1 3 years ago
24.rkt d24 p1 3 years ago
24.rktd d24 p1 3 years ago
25.rkt d25 start 3 years ago
25.rktd d25 start 3 years ago
README.md Update README.md 3 years ago


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 🤘