#-------------------------------------------------------------------------------
# Load libraries
#-------------------------------------------------------------------------------
# Load the crud library
devtools::load_all()
devtools::document()
# Load external packages
pckgs <- c("here", "tidyverse", "magrittr")
adventofcode2017::ipak(pckgs)
# Data directory
DATA_DIR <- file.path(here::here(), "tests/testthat/data")
#-------------------------------------------------------------------------------
# Exercise Day 01-01 Solution
#-------------------------------------------------------------------------------
# Define the input string
inp_day_01 <- file.path(DATA_DIR, "input-day-01.txt")
# Run through day-01 functions to obtain solution
inp_day_01 %>%
base::readLines(con = .) %>%
base::as.character() %>%
adventofcode2017::calc_sum_lag(inp_val = ., lag_val_fixed = TRUE)
#-------------------------------------------------------------------------------
# Exercise Day 01-02 Solution
#-------------------------------------------------------------------------------
# This time we use the lag rule using the automatically worked out
# lag-value as half the length of the input vector (assumed to be even)
inp_day_01 %>%
base::readLines(con = .) %>%
base::as.character() %>%
adventofcode2017::calc_sum_lag(inp_val = .
, lag_val_fixed = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.