Package 'aoc.elf'

Title: Tan's Helper Functions for Advent of Code
Description: Helpers for downloading Advent of Code answers. Eventually will help submit also?
Authors: Tan Ho [aut, cre]
Maintainer: Tan Ho <[email protected]>
License: MIT + file LICENSE
Version: 0.15.0
Built: 2024-10-03 02:42:11 UTC
Source: https://github.com/tanho63/aoc.elf

Help Index


Get puzzle for day

Description

Requires AOC_COOKIE environment variable to be set. Downloads and caches puzzle inputs onto your machine.

Usage

aoc_get(
  day,
  year = format(Sys.Date(), "%Y"),
  path = here::here(),
  overwrite = FALSE,
  open = Sys.getenv("AOC_OPEN", unset = interactive())
)

Arguments

day

the day of the puzzle

year

year of puzzle, defaults to current year

path

path to copy template to, defaults to subfolders of current directory

overwrite

overwrite existing file, default to interactive()

Value

Returns the timestamp, in case you're keen on timing your results.


Copy Template for Day

Description

This function copies the bundled RMarkdown template into a folder within the (current) path, creating a subfolder for the year if necessary and pre-filling variables

Usage

aoc_init(
  day,
  year = format(Sys.Date(), "%Y"),
  path = here::here(),
  overwrite = FALSE,
  template = Sys.getenv("AOC_TEMPLATE", unset = "default"),
  open = Sys.getenv("AOC_OPEN", unset = "true")
)

Arguments

day

the day of the puzzle

year

year of puzzle, defaults to current year

path

path to copy template to, defaults to subfolders of current directory

overwrite

overwrite existing file, default to FALSE

open

open file for editing, if RStudio is available

Value

opens the template


Read to tibble

Description

Reads in input lines into a tibble and optionally tries type detection

Usage

aoc_read(day, year = format(Sys.Date(), "%Y"), convert = TRUE)

Arguments

day

the day of the puzzle

year

year of puzzle, defaults to current year

convert

logical: whether to run readr::type_convert() or not


Set AOC configuration options

Description

AOC author will also try to read options("usethis.full_name") for the author's name, if this environment variable is not set.

Usage

aoc_set_cookie(cookie)

aoc_set_author(author)

Arguments

cookie

a character string of the session cookie as found with network tools

author

Author name, for template

Value

sets environment variable and returns success message

sets environment variable and returns success message