Implement day 25.

Part 2 was bonkers.
This commit is contained in:
2018-12-25 11:28:58 +01:00
parent 4a5bec0e7d
commit 22c71dc3f5
8 changed files with 148 additions and 9 deletions

View File

@@ -43,6 +43,21 @@ impl<T> Point for (T, T, T)
}
}
impl<T> Point for [T; 4]
where T: Default + Add<Output=T> + Sub<Output=T> + Copy + Ord
{
type CoordType = T;
fn manhattan(self, other: Self) -> T {
let mut dist = T::default();
for (&a, b) in self.iter().zip(other.iter()) {
dist = dist + a.max(*b) - a.min(*b);
}
dist
}
}
/// Apply Erathostenes's sieve to the supplied array
///