Advent of Code
(require advent-of-code) | package: advent-of-code |
A package for fetching Advent of Code input.
1 Input Fetching
(require advent-of-code/input) | package: advent-of-code |
procedure
(open-aoc-input session year day [ #:cache cache]) → input-port? session : aoc-session? year : advent-year? day : advent-day? cache : (or/c boolean? path-string?) = #f
If you are using this in your puzzle solution, use of the cache argument is highly recommended.
See aoc-request for information on session, caching and error handling.
procedure
(fetch-aoc-input session year day [ #:cache cache]) → string? session : aoc-session? year : advent-year? day : advent-day? cache : (or/c boolean? path-string?) = #f
See open-aoc-input.
value
Equivalent to (integer-in 1 25).
value
Equivalent to (and/c exact-integer? (>=/c 2015)).
2 Automatic Submission
(require advent-of-code/answer) | package: advent-of-code |
This module also reprovides advent-year? and advent-day?
procedure
(aoc-submit session year day part answer) → string?
session : aoc-session? year : advent-year? day : advent-day? part : (or/c 1 2) answer : any/c
answer will be formatted with display before being submitted.
Returns the string that the Advent of Code site returns, to be read by a human.
procedure
(aoc-submit* session year day part answer) → input-port?
session : aoc-session? year : advent-year? day : advent-day? part : (or/c 1 2) answer : any/c
This is the HTML page that the site shows the user upon submitting an answer.
3 Requests
(require advent-of-code/request) | package: advent-of-code |
Procedures for making API requests. Reprovided by advent-of-code.
procedure
(aoc-session? x) → boolean?
x : any/c
Equivalent to string?.
struct
(struct exn:fail:aoc exn:fail (status) #:extra-constructor-name make-exn:fail:aoc) status : string?
procedure
(aoc-request session path ... [ #:cache cache #:post post?]) → input-port? session : aoc-session? path : any/c cache : (or/c boolean? path-string?) = #f
post? : (or/c #f bytes? string? input-port? payload-procedure/c) = #f
If post? is supplied, then it is POST-ed as the payload, otherwise a simple GET request is made.
The cache argument specifies how the data should be cached.
If cache is #f, then no caching is performed, meaning the HTTP request will be made to the website every time. This is the default.
If cache is a path-string?, then the provided path is used as the directory to cache requests in.
If cache is a #t, then (find-system-path 'cache-dir) is used as the directory to cache requests in.
Raises exn:fail:aoc if the request fails.
4 Meta and Environment Utilities
(require advent-of-code/meta) | package: advent-of-code |
Meta and environment functions. Reprovided by advent-of-code.
procedure
value
procedure
Tries to read session-file, if it is less than one month old, otherwise interactively prompts the user to enter the session cookie themselves, and saves it in session-file for later.
This is meant to be used by interactive programs, since it reads from current-input-port and writes to current-output-port.