Skip to content

bodkan/adventofcode2021

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ„ Advent of Code 2021 in R πŸŽ„

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.

Solutions

Why on Earth would you use R for this?

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).

Personal stats

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. Β―\_(ツ)_/Β―

image

About

πŸŽ„ Advent of Code 2021 in R πŸŽ„

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks