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
.
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. ¯\_(ツ)_/¯
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.