1
0
Fork
You've already forked aoc-2024
0
My solutions for Advent of Code 2024. This is a mirror of the GitHub repository. https://github.com/beeb/aoc-2024
  • Rust 99.2%
  • Nix 0.8%
2025年01月12日 20:37:36 +01:00
inputs Initial commit 2024年11月29日 15:44:40 +01:00
src docs(day24): add comment 2025年01月12日 20:37:36 +01:00
.envrc feat: trim empty lines at end of input file 2024年11月29日 15:51:45 +01:00
.gitignore feat: trim empty lines at end of input file 2024年11月29日 15:51:45 +01:00
Cargo.toml feat(day23): part 1 2024年12月23日 12:21:59 +01:00
flake.lock feat: day 1 2024年12月01日 09:24:12 +01:00
flake.nix Initial commit 2024年11月29日 15:44:40 +01:00
graph.dot feat(day23): part 1 2024年12月23日 12:21:59 +01:00
README.md Initial commit 2024年11月29日 15:44:40 +01:00
rust-toolchain.toml Initial commit 2024年11月29日 15:44:40 +01:00

Advent of Code Rust template

This is a basic template you can fork and implement your Advent of Code solutions in. src/days/ contains a source file for all 25 days, where an implementation of a trait Day should be written.

pubtraitDay{type Input;fn parser(input_string: &mut&str)-> PResult<Self::Input>;type Output1: Display;fn part_1(input: &Self::Input)-> Self::Output1;type Output2: Display;fn part_2(input: &Self::Input)-> Self::Output2;}

The parsers should be written using winnow.

Dev shell

A flake.nix provides a nix dev shell with the rust toolchain installed. Enter the shell by running nix develop (requires the nix-command and flakes experimental features)

Usage

First, modify the package metadata in Cargo.toml and change the current YEAR constant in src/main.rs.

Then, find your session cookie. To do so, go to https://adventofcode.com, log in, and press F12. In the "Application" tab, under "Storage > Cookies > https://adventofcode.com", copy the value of the "session" cookie. Paste it into a file named .session at the root of the project. You can now download input files. To do so, run the subcommand get: cargo run -- get 1. The 1 stands for day 1, meaning it will download the input of day 1 of Advent of Code. Alternatively, from December 1st to 25th, you can skip the day parameter, and the program will download today's input. You can also use --all instead of a day parameter to download all input files.

To run your implementation, use cargo run [-r] -- run 1 (-r for release profile) to run day 1. Just like get,you can skip the day parameter to run today's program, or use --all to run all days.