copy manhattan distance and compare

This commit is contained in:
Baipyrus 2024-01-28 00:03:00 +01:00
parent 52d5b5949c
commit 53158f011b

View File

@ -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<Vec<Block>> {
let name = "day17";
println!("Executing module '{name}' entrypoint . . . ");