Implement day 5

Nom is really nice and fast, why did I write parsers manually before.
This commit is contained in:
2021-12-05 11:31:14 +01:00
parent 5e52da6e6b
commit 1433b0cdbe
6 changed files with 619 additions and 4 deletions

View File

@@ -60,3 +60,12 @@ impl<'a, I: FromStr> Iterator for LineParser<'a, I> {
self.iter.next()?.parse().ok()
}
}
/// Return two arguments in their natural PartialOrd order
pub fn ordered<O: PartialOrd>(a: O, b: O) -> (O, O) {
if a < b {
(a, b)
} else {
(b, a)
}
}