This commit is contained in:
Daniel Flanagan 2024-12-02 10:18:54 -06:00
parent c5671587d5
commit 5bb3c29741

View file

@ -6,6 +6,7 @@ fn main() {
show_answers(note.smallests_distances(), note.similarity_score());
}
#[derive(Default)]
struct HistorianNote {
left: Vec<i64>,
right: Vec<i64>,
@ -14,14 +15,13 @@ struct HistorianNote {
impl FromStr for HistorianNote {
type Err = ParseIntError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut result = Self::default();
let mut line_tokens = s.lines().map(|l| l.split_once(" "));
let mut left = Vec::<i64>::new();
let mut right = Vec::<i64>::new();
while let Some((l, r)) = line_tokens.next().flatten() {
left.push(l.parse()?);
right.push(r.parse()?);
result.left.push(l.parse()?);
result.right.push(r.parse()?);
}
Ok(Self { left, right })
Ok(result)
}
}