You cannot 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.
aoc-racket/2019/README.md

36 lines
1.9 KiB
Markdown

4 years ago
## MBs Advent of Code tips
4 years ago
* 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.
4 years ago
* Complex numbers are a nice way of modeling two-dimensional positions.
4 years ago
* Use lists whenever feasible, because there are many useful list functions in the Racket library that dont have vector equivalents. In particular, [these list functions](https://docs.racket-lang.org/reference/pairs.html?q=racket%2Flist#%28part._.Additional_.List_.Functions_and_.Synonyms%29) are very useful, especially `argmin` and `argmax`.
4 years ago
4 years ago
* Vectors are better than lists in situations where you need random access to members.
4 years ago
4 years ago
* `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.
4 years ago
* Association lists (= lists of pairs) are underrated. Theyre 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.
* Its good to know about sets and mutable pairs.
* Also the fancier `for` iterators, like `for/first` and `for/or`.
4 years ago
* `let/ec` is a way of jumping out of a deeply nested computation, akin to how `return` works in other languages.
4 years ago
4 years ago
## My solutions
4 years ago
* I try to write solutions that are succinct but not cryptic.
4 years ago
4 years ago
* I dont optimize for speed.
* I like doing the Advent of Code problems because it forces me to use parts of Racket that I dont ordinarily use. So I treat it as a chance to expand my awareness of the Racketverse.
4 years ago
* Im unlikely to finish every problem. Judging by past years, there is a point where the problems get sufficiently complex that Id rather put that time into improving my other Racket projects :metal: