~swaits/aoc2021

5dd0fc28623deb7a2b6aaa916ef37b7f6554b9e1 — Stephen Waits 1 year, 9 months ago 7e5ea23
minor day 8 tweak
1 files changed, 5 insertions(+), 1 deletions(-)

M src/day08.rs
M src/day08.rs => src/day08.rs +5 -1
@@ 5,7 5,11 @@ use itertools::Itertools;
// NOTE: this is O(n^2), but our input is tiny
//       a HashSet is better complexity, but the allocations will hurt us
fn shared_chars(a: &str, b: &str) -> usize {
    a.chars().filter(|c| b.contains(&c.to_string())).count()
    if a.len() < b.len() {
        a.chars().filter(|ch| b.contains(&ch.to_string())).count()
    } else {
        b.chars().filter(|ch| a.contains(&ch.to_string())).count()
    }
}

// decode a set of 10 input + 4 output characters and return the output