Implement day 14.

This commit is contained in:
2018-12-14 11:37:30 +01:00
parent faf3ad90d9
commit 98da0a9857
3 changed files with 106 additions and 5 deletions

View File

@@ -1,6 +1,8 @@
use std::collections::HashMap;
use std::hash::Hash;
use std::io;
use std::io::Read;
use std::str::FromStr;
/// Apply Erathostenes's sieve to the supplied array
///
@@ -50,6 +52,19 @@ pub fn trim_back(input: &mut Vec<u8>) {
}
}
/// Read the entire input as one value.
///
/// This function loads the input into a string and then attempts to parse it.
pub fn read_single_input<T>(input: &mut Read) -> T
where T: FromStr,
<T as FromStr>::Err: std::fmt::Debug
{
let mut buf = String::new();
input.read_to_string(&mut buf).unwrap();
buf.trim().parse().unwrap()
}
/// An interface to count elements in particular categories.
pub trait GroupingCount {