yescallop / aoc

My solutions to Advent of Code puzzles.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

aoc

This repository holds my solutions to Advent of Code puzzles, written in Rust, licensed under the MIT License.

Using this crate as a template

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

  1. 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.

  2. Cookie file (cookie.txt) is needed, with contents session=<obtained from your browser>.

  3. This includes updating the module declarations and the push_sols macro call.

About

My solutions to Advent of Code puzzles.

License:MIT License


Languages

Language:Rust 100.0%