Day 22, part 1

This commit is contained in:
jazzpi
2022-12-22 12:57:38 +01:00
parent a0fa5256e9
commit 5e6870d092
5 changed files with 239 additions and 7 deletions

18
src/bin/d22p1.rs Normal file
View File

@ -0,0 +1,18 @@
use aoc22::{day22, util};
pub fn main() {
let (grid, instructions) = day22::parse_map_and_path(&util::parse_input());
// dbg!(&grid);
// dbg!(&instructions);
let mut pose = day22::Pose::new(&grid);
// dbg!(&pose);
for inst in &instructions {
pose = day22::exec_instruction(&grid, &pose, inst);
// dbg!(&pose);
}
let pass = 1000 * (pose.pos.0 + 1) + 4 * (pose.pos.1 + 1) + (pose.orientation as usize);
println!("Passowrd: {}", pass);
}