This repository contains my solutions to the Advent of Code 2021 in R. My goal is to solve every puzzle using nothing else but base R functions and without any data frames or data frame manipulation functions (matrices, n-dimensional arrays and linear algebra operations are OK).
The "solutions as an R package" method is inspired by @tjmahr's approach to Advent of Code 2017. Briefly, each script under R/
contains the functions needed to solve the puzzle on a given day. Unit tests under tests/
verify that my solutions adhere to the requirements given by each puzzle specification, using the tiny testing data on the Advent of Code website. Finally, inst/
contains small standalone R scripts which solve the full puzzles stored in text files under inst/extdata
and output the results to the terminal. All are executed by a master script in inst/run-all.R
.
- Day 1 puzzle - my solution
- Day 2 puzzle - my solution
- Day 3 puzzle - my solution
- Day 4 puzzle - my solution
- Day 5 puzzle - my solution
- Day 6 puzzle - my solution
- Day 7 puzzle - my solution
- Day 8 puzzle - my solution
- Day 9 puzzle - my solution
- Day 10 puzzle - my solution
- Day 11 puzzle - my solution
- Day 12 puzzle - my solution
- Day 13 puzzle - my solution
- Day 14 puzzle - my solution
- Day 15 puzzle - my solution
- Day 16 puzzle - my solution
- Day 17 puzzle - my solution
- Day 18 puzzle - my solution
- Day 19 puzzle - my solution
- Day 20 puzzle - my solution
- Day 21 puzzle - my solution
- Day 23 puzzle - No code! The puzzle (both parts 1 and 2) was turned into a boardgame and solved manually as a Christmas family activity. :)
Several reasons. First, R is my favourite programming language. There, I said it.
Second, I spend nearly all time at my job doing data analysis and researchβnearly everything I work with on a daily basis are (gigantic) tables, the usual output of my work are figures and statistical models. Advent of Code presents a very different class of problems that I rarely get to work with these days and it seemed like a fun challenge trying to solve them in R. Moreover, as an additional challenge and a character building experience I decided to restrict myself to only use features available in base R 4.x without any additional packages and without using any data frames or functions that manipulate them (again, something that is very unusual when working with R).
As you can see, I've been approaching this very casually. π π πΉ Working on this during breaks throughout the day, so there's no way I will ever score well. Β―\_(γ)_/Β―