8.18
top
← prev up next →

Advent of CodeπŸ”— i

eutro

A package for fetching Advent of Code input.

1Input FetchingπŸ”— i

procedure

( open-aoc-input session
year
day
[ #:cachecache])input-port?
session:aoc-session?
Fetch the puzzle input for day of year as an input port.

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
[ #:cachecache])string?
session:aoc-session?
Fetch the input data as a string, using open-aoc-input .

See open-aoc-input .

A day of the month between 1 and 25.

Equivalent to (integer-in 125).

A year since 2015.

Equivalent to (and/c exact-integer? (>=/c 2015)).

2Automatic SubmissionπŸ”— i

This module also reprovides advent-year? and advent-day?

procedure

( aoc-submit sessionyeardaypartanswer)string?

session:aoc-session?
part:(or/c 12)
answer:any/c
Submit answer as an answer to the given puzzle.

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* sessionyeardaypartanswer)input-port?

session:aoc-session?
part:(or/c 12)
answer:any/c
Like aoc-submit , but yields the full port containing the response to the request.

This is the HTML page that the site shows the user upon submitting an answer.

3RequestsπŸ”— i

Procedures for making API requests. Reprovided by advent-of-code.

procedure

( aoc-session? x)boolean?

x:any/c
Predicate for an Advent of Code session cookie.

Equivalent to string? .

value

aoc-url :url?

struct

#:extra-constructor-namemake-exn:fail:aoc)
status:string?
Raised by aoc-request if a request fails.

procedure

( aoc-request session
path...
[ #:cachecache
#:postpost?])input-port?
session:aoc-session?
path:any/c
Makes an HTTP GET or POST request to the Advent of Code website, using the given session cookie.

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.

4Meta and Environment UtilitiesπŸ”— i

Meta and environment functions. Reprovided by advent-of-code.

procedure

( current-aoc-time )date?

The current EST (UTC-5) time, on which the Advent of Code calendar is based.

The path of the file used to fetch the current session by find-session .

procedure

( find-session )aoc-session?

Attempt to find a valid aoc-session? for the user.

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 .

top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /