prepare files y2024d16

This commit is contained in:
2024-12-16 11:24:17 +01:00
parent 312460ffa5
commit b20aa6fbdc
4 changed files with 234 additions and 0 deletions

27
y2024/src/bin/d16.rs Normal file
View File

@@ -0,0 +1,27 @@
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2024::days::d16;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/16_input.txt")).unwrap();
println!("{}", d16::process_part1(&content));
}
fn part2() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/16_input.txt")).unwrap();
println!("{}", d16::process_part2(&content));
}

64
y2024/src/days/d16.rs Normal file
View File

@@ -0,0 +1,64 @@
pub fn process_part1(input: &str) -> i32 {
0
}
pub fn process_part2(input: &str) -> i32 {
0
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT_1: &str = "###############
#.......#....E#
#.#.###.#.###.#
#.....#.#...#.#
#.###.#####.#.#
#.#.#.......#.#
#.#.#####.###.#
#...........#.#
###.#.#####.#.#
#...#.....#.#.#
#.#.#.###.#.#.#
#.....#...#.#.#
#.###.#.#.#.#.#
#S..#.....#...#
###############";
const INPUT_2: &str = "#################
#...#...#...#..E#
#.#.#.#.#.#.#.#.#
#.#.#.#...#...#.#
#.#.#.#.###.#.#.#
#...#.#.#.....#.#
#.#.#.#.#.#####.#
#.#...#.#.#.....#
#.#.#####.#.###.#
#.#.#.......#...#
#.#.###.#####.###
#.#.#...#.....#.#
#.#.#.#####.###.#
#.#.#.........#.#
#.#.#.#########.#
#S#.............#
#################";
#[test]
fn part1_1() {
let result = process_part1(INPUT_1);
assert_eq!(result, 7036);
}
#[test]
fn part1_2() {
let result = process_part1(INPUT_2);
assert_eq!(result, 11048);
}
#[test]
fn part2() {
let result = process_part2(INPUT_1);
assert_eq!(result, 0);
}
}

View File

@@ -19,3 +19,5 @@ pub mod d13;
pub mod d14;
pub mod d15;
pub mod d16;