day 4 (rs)
cleanup
day 3 (rs)
Advent of Code is back again. And once again I'm trying to solve it.
Here you'll find solutions to the puzzles in the following languages:
More to come, maybe.
I belive my tools adhere to the Advent of Code automation guidelines.
https://adventofcode.com/$YEAR/day/$DAY/input
.inputs/day_$DAY.txt
no requests are issued,
User-Agent
is set to git.sr.ht/~cdv/aoc-2023 (<relative path to file/module issuing the requests> ; <library used>/<version>) by chris@vittal.dev
git.sr.ht/~cdv/aoc-2023 (rs/x.py ; requests/2.28.1) by chris@vittal.dev
Each implementation has a few quirks. I try to document them below, as well as provide instructions on how to build/run every solution.
This uses nightly rust for certain const generic functions.
Every solution is it's own binary day01
to day25
that takes inputs on
standard input and writes both parts to standard output.
cargo run --bin "day13" < input/day_13.txt
There is also a convenience script x.py
that will download input and run
solutions.
It is configured with an aoc.toml
file:
# aoc.toml for configuring x.py helper
year = 2023
session = 'session token'
input_dir = '../input'
To use the x.py
script:
$ ./x.py -h
usage: x.py [-h] [--refresh] [--all] [--config CONFIG] [--debug]
[--verbose | --quiet]
[day ...]
Advent of Code helper for rust solutions
positional arguments:
day days to run
optional arguments:
-h, --help show this help message and exit
--refresh, -r force a refresh of the puzzle input
--all, -a run all days
--config CONFIG, -C CONFIG
TOML config file to use
--debug build/run solutions in debug mode
--verbose, -v increase messaging
--quiet, -q reduce messaging
Built with the meson build system. Tested on macOS and Linux, may work elsewhere, especially on other POSIX systems.
There is also a binary (aocc
in c/util/run.c), that can build the binaries, download the inputs, and run the solutions.
It depends on libcurl and jansson.
meson setup build --buildtype=release
ninja -C build
build/day13 < input/day_13.txt
aocc
build/aocc 13
aocc
aocc
accepts the following command line flags and arguments.
aocc [-rav] [-c <config]] [-C <dir>] <days>...
-r Always download new input
-a Run all days (will not run future days)
-v Print more information
-c <config> Use config rather than 'aoc.json'
-C <dir> Change to directory 'dir' before executing
<days>... If -a was not specified, run all days
It's config file, aoc.json
should have the following fields
{
"year": 2021,
"session": "your session cookie string",
"input_dir": "where your inputs live",
"build_dir": "where the project build directory is, ususally build"
}
The python solutions are all contained in an aoc
module. It use requests to
download necessary inputs and toml for configuration.
python -m aoc -h
usage: __main__.py [-h] [--refresh] [--all] [--stdin] [day ...]
positional arguments:
day days to run
optional arguments:
-h, --help show this help message and exit
--refresh force a refresh of the puzzle input
--all, -a run all days
--stdin read input from stdin, (only if only one day specified)
Of note is the --stdin
option, if only one day is specified (no days defaults
to today), then the input can be passed on standard input.
# aoc.toml for configuring python solutions
year = 2023
session = 'session token'
input_dir = '../input'