Implement day23 part 1.

This commit is contained in:
2018-12-23 07:07:02 +01:00
parent a052d3a4fe
commit 85538d2fc6
5 changed files with 1084 additions and 4 deletions

View File

@@ -31,6 +31,18 @@ impl<T> Point for (T, T)
}
}
impl<T> Point for (T, T, T)
where T: Add<Output=T> + Sub<Output=T> + Copy + Ord
{
type CoordType = T;
fn manhattan(self, other: Self) -> T {
let (xa, ya, za) = self;
let (xb, yb, zb) = other;
xa.max(xb) + ya.max(yb) + za.max(zb) - xa.min(xb) - ya.min(yb) - za.min(zb)
}
}
/// Apply Erathostenes's sieve to the supplied array
///