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 the
solutions adhere to the requirements given by each puzzle specification, using
the tiny testing data from the Advent of Code page for each day. Finally,
inst/ contains small standalone R scripts which solve the full puzzles stored
in text files under inst/extdata and print the results to the terminal. All
of these solutions can be executed by a master script 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 22 puzzle - my solution
- Day 23 puzzle - No code! I turned the puzzle into a "boardgame" and we solved it as a 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 scienceโnearly everything I work with on a daily basis takes form of a (gigantic) table, and the purpose of my work is to produce figures, statistical models, and gain scientific insights. 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, for an extra character building challenge, I decided to restrict myself to only use features available in base R 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).