#![feature(let_chains)] #![feature(string_remove_matches)] mod day1; mod day2; mod day3; mod day4; mod day5; mod day6; mod day7; mod utils; use utils::Part; fn main() { env_logger::builder() .filter_level(log::LevelFilter::Debug) .format_timestamp(None) .init(); let data = utils::lines_from_file("./datasets/adventofcode.com_2023_day_7_input.txt").expect("Can't load the data"); //let data = utils::lines_from_file("./datasets/test.txt").expect("Can't load the data"); } #[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); } #[test] fn day4() { let data_path = "./datasets/adventofcode.com_2023_day_4_input.txt"; let result = day4::solve(utils::lines_from_file(data_path).expect("Could not load the dataset for day 3"), Part::One); let result2 = day4::solve(utils::lines_from_file(data_path).expect("Could not load the dataset for day 3"), Part::Two); assert_eq!(result, 20407); assert_eq!(result2, 23806951); } #[test] fn day6() { let data_path = "./datasets/adventofcode.com_2023_day_6_input.txt"; let result = day6::solve(utils::lines_from_file(data_path).expect("Could not load the dataset for day 3"), Part::One); let result2 = day6::solve(utils::lines_from_file(data_path).expect("Could not load the dataset for day 3"), Part::Two); assert_eq!(result, 2612736); assert_eq!(result2, 29891250); } }