diff --git a/README.md b/README.md index d611802..73d2b86 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ Solutions for [Advent of Code](https://adventofcode.com/) in [Rust](https://www. | Day | Part 1 | Part 2 | | :---: | :---: | :---: | | [Day 1](./src/bin/01.rs) | `72.0µs` | `76.8µs` | -| [Day 2](./src/bin/02.rs) | `333.6µs` | `642.1µs` | +| [Day 2](./src/bin/02.rs) | `215.6µs` | `371.6µs` | -**Total: 1.12ms** +**Total: 0.74ms** --- diff --git a/src/bin/02.rs b/src/bin/02.rs index 95166cc..378a045 100644 --- a/src/bin/02.rs +++ b/src/bin/02.rs @@ -2,7 +2,7 @@ advent_of_code::solution!(2); use std::cmp::Ordering; -fn validate_input_p1(input: &Vec) -> bool { +fn validate_input_p1(input: &[u32]) -> bool { input .iter() .fold( @@ -30,7 +30,7 @@ fn validate_input_p2(input: &Vec) -> bool { } for i in 0..input.len() { - let mut input2 = input.clone(); + let mut input2 = input.to_owned(); input2.remove(i); if validate_input_p1(&input2) { return true; @@ -50,7 +50,7 @@ pub fn part_one(input: &str) -> Option { .map(|nb| nb.parse::().expect("parsing failed")) .collect::>() }) - .filter(validate_input_p1) + .filter(|s| validate_input_p1(s)) .count() .into() }