This repository holds my solutions to Advent of Code puzzles, written in Rust, licensed under the MIT License.
Replace the solutions with your own, cargo run
, and you're done.
The latest solution is run by default1, against the puzzle input fetched from the website2 or local cache.
Here is an example of solution code (typically located at /src/solution/year_2077.rs
):
use super::*;
impl Solution<2077, 1> for Puzzle {
fn solve(&mut self) -> Result<()> {
self.output(self.input.len());
self.output(self.input.lines().count());
Ok(())
}
}
Running this solution against an input of 100
bytes and 10
lines, the program would print the following:
(year, day) = (2077, 1)
out[0] = 100
out[1] = 10
Typically you won't need to modify anything else, except for some small initialization3 before a new year's work.
Footnotes
-
To run a specific solution, pass in the arguments
year day
. You may omit the day (year) to run the latest (a specific) solution in a specific (the latest) year. ↩ -
Cookie file (
cookie.txt
) is needed, with contentssession=<obtained from your browser>
. ↩ -
This includes updating the module declarations and the
push_sols
macro call. ↩