aochelpers

aochelpers is a companion package to the Advent of Code website template: https://github.com/EllaKaye/advent-of-code-website-template/. It contains functions to create new listings and posts corresponding to years and days of the Advent of Code challenges. It also contains functions to download and save puzzle input from the Advent of Code website, and to read it in to R in a variety of formats. In time, I will add functions that are useful in solving the puzzles.

The functions are designed to be used in conjunction with the Advent of Code website template, and so are easier to demonstrate in that context than here, so see the repo https://github.com/EllaKaye/advent-of-code-website-template/ and the corresponding demo site, https://ellakaye.github.io/advent-of-code-website-template/, for further documentation and an example.

Installation

You can install the development version of aochelpers from GitHub with:

# install.packages("remotes")
# remotes::install_github("EllaKaye/aochelpers")
install.packages("aochelpers", repos = c('https://ellakaye.r-universe.dev', 'https://cloud.r-project.org'))

Adding listings pages and posts

The main functions in aochelpers are aoc_new_year() and aoc_new_day(). They copy files from the website’s "_template" directory, and paste them into the appropriate location in the website directory. Moreover, in the copies, they replace any instances of YYYY and DD in the templates with the values of the year and day arguments, respectively, both in the directory and file names, and in the contents of the .qmd files themselves. In the descriptions below, the YYYY and DD placeholders are used to indicate where the year and day values will be inserted.

library(aochelpers)
# Add a listing page a directory for a new year
aoc_new_year() # current year
aoc_new_year(2022) # specified year

# Add a post for a new day
aoc_new_day(1) # day 1 of current year
aoc_new_day(2, 2022) # day 2 of specified year

aoc_new_year() will

aoc_new_day() will

See the advent-of-code-website-template repo for further details about the default contents of _templates.

There are other functions for creating and deleting directories and files based on the advent-of-code-website-template. See the Reference page for details.

Reading in puzzle input

aochelpers provides a number of functions to read in puzzle input, once saved from the Advent of Code website. The functions are designed to be used in conjunction with the Advent of Code website template, so to see the output of the functions, see the repo https://github.com/EllaKaye/advent-of-code-website-template/ and the corresponding site, https://ellakaye.github.io/advent-of-code-website-template/, for examples of their output.

aoc_input_vector(1, 2022, "numeric")
aoc_input_data_frame(2, 2022)