mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Implement day 14.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user