Giter Club home page Giter Club logo

aoc-racket's Introduction

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.

aoc-racket's People

Contributors

bennn avatar mbutterick avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.