From 53158f011be809b38938c9eae99141680b87f1b8 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Sun, 28 Jan 2024 00:03:00 +0100 Subject: [PATCH] copy manhattan distance and compare --- src/day17/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/day17/mod.rs b/src/day17/mod.rs index 0509cbe..08cd667 100644 --- a/src/day17/mod.rs +++ b/src/day17/mod.rs @@ -16,6 +16,18 @@ struct Block { y: usize, } +impl Block { + fn distance(&self, other: &Block) -> i32 { + let dx = (other.x as i32 - self.x as i32).abs(); + let dy = (other.y as i32 - self.y as i32).abs(); + dx + dy + } + + fn compare(&self, other: &Block) -> bool { + self.x == other.x && self.y == other.y + } +} + fn setup() -> Vec> { let name = "day17"; println!("Executing module '{name}' entrypoint . . . ");