Advent of Code in rust
Go to file
Mathis 8c45193f56 2023-17: Set as unfinished 2023-12-25 18:14:31 +01:00
.vscode 2023-08: Implement first part 2023-12-19 21:59:45 +01:00
input/2023 2023-17: Fix edge cost bug 2023-12-25 16:50:08 +01:00
src 2023-17: Set as unfinished 2023-12-25 18:14:31 +01:00
.gitignore Ignore .vscode 2023-12-25 01:02:50 +01:00
Cargo.toml 2023-08: Implement first part 2023-12-19 21:59:45 +01:00
README.md Add README 2023-12-25 18:14:12 +01:00

README.md

Advent Of Code

Year Lang Stars
2023 Rust 24

Rust

  1. Create folder src/year_2023/day_XX_name

  2. Create mod.rs, part_one.rs, Optionally common.rs, part_two.rs

  3. Edit mod.rs

pub mod part_one;
pub mod part_two;
pub mod common;

use crate::utils::solution::Solution;
use crate::utils::input_reader;

pub struct DaySolution ;


impl Solution for DaySolution {

    fn input_path(&self) -> &'static str {
        "input/XXXX/day_XX/input.txt"
    }

    fn part_one(&self) -> String {
        input_reader::read_input_file(self.input_path(), part_one::part_one)
    }

    fn part_two(&self) -> String {
        input_reader::read_input_file(self.input_path(), part_two::part_two)
        // String::from("Not implemented")
    }
}
  1. Edit mod.rs in year_XXXX folder
pub mod day_XX_problem_name;
//...
let solution: Box<dyn Solution> = match day {
        // ...
        "XX" => Box::new(day_XX_problem_day::DaySolution),
        // ...
  1. Copy input into input/XXXX/day_XX/input.txt

  2. Run

cargo run <year> <day>