Skip to contents

Read in the puzzle input, or other file, as a matrix, one row per line, by default one character per column. It assumes that the file is stored in the directory "./YYYY/day/DD", where YYYY and DD are the values of year and day. By default, the file name is "input". This file will exist in this location if the post was created using aoc_new_day(). The initial reading is done by readLines().

Usage

aoc_input_matrix(
  day,
  year = NULL,
  file = "input",
  mode = c("character", "numeric"),
  split = "",
  view = FALSE
)

Arguments

day

An integer between 1 and 25

year

An integer representing the year, from 2015 to the current year. Defaults to the current year.

file

Character string. The name of a file that exists in the directory "./YYYY/day/DD", where YYYY and DD are the values of year and day. Defaults to "input".

mode

Character string. One of 'character' or 'numeric'. Default is 'character'.

split

character. The string to split the input on. Default is "", i.e. one character per column

view

logical. If TRUE, calls utils::View() to view the returned input. Default is FALSE

Value

A matrix containing the puzzle input for the day and year.

Examples

if (FALSE) aoc_input_matrix(3, 2020)