54 lines
1.6 KiB
Rust
54 lines
1.6 KiB
Rust
#![feature(let_chains)]
|
|
|
|
mod day1;
|
|
mod day2;
|
|
mod day3;
|
|
mod utils;
|
|
use utils::Part;
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
env_logger::builder()
|
|
.filter_level(log::LevelFilter::Debug)
|
|
.format_timestamp(None)
|
|
.init();
|
|
}
|
|
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn day1() {
|
|
let day1_data_path = "./datasets/adventofcode.com_2023_day_1_input.txt";
|
|
let day1_result_part1 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), Part::One);
|
|
let day1_result_part2 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), Part::Two);
|
|
|
|
assert_eq!(day1_result_part1, 54338);
|
|
assert_eq!(day1_result_part2, 53389);
|
|
}
|
|
|
|
#[test]
|
|
fn day2() {
|
|
let data_path = "./datasets/adventofcode.com_2023_day_2_input.txt";
|
|
let result = day2::solve(utils::lines_from_file(data_path).expect("Could not load the dataset for the day"), Part::One);
|
|
let result2 = day2::solve(utils::lines_from_file(data_path).expect("Could not load the dataset for the day"),Part::Two);
|
|
|
|
|
|
assert_eq!(result, 2795);
|
|
assert_eq!(result2, 75561);
|
|
}
|
|
|
|
#[test]
|
|
fn day3() {
|
|
let data_path = "./datasets/adventofcode.com_2023_day_3_input.txt";
|
|
let result = day3::solve(utils::lines_from_file(data_path).expect("Could not load the dataset for day 3"), Part::One);
|
|
let result2 = day3::solve(utils::lines_from_file(data_path).expect("Could not load the dataset for day 3"), Part::Two);
|
|
|
|
assert_eq!(result, 522726);
|
|
assert_eq!(result2, 81721933);
|
|
}
|
|
} |