This commit is contained in:
nora 2023-12-12 19:47:48 +01:00
parent 547882d18f
commit 01e3733421
6 changed files with 10 additions and 8 deletions

View file

@ -6,7 +6,7 @@ fn line_match_count(line: &str) -> usize {
.split_ascii_whitespace()
.collect::<arrayvec::ArrayVec<_, 16>>();
let you_have = numbers.next().unwrap().split_ascii_whitespace();
let you_have = numbers.next().unwrap().split_ascii_whitespace();
you_have
.filter(|have| winning.iter().any(|w| w == have))

View file

@ -4,7 +4,11 @@ fn line_match_count(line: &str) -> usize {
((chunk[1] as u16) << 8) | (chunk[2] as u16)
}
let mut numbers = line.split(|&b| b == b':').nth(1).unwrap().split(|&b| b == b'|');
let mut numbers = line
.split(|&b| b == b':')
.nth(1)
.unwrap()
.split(|&b| b == b'|');
let winning = numbers
.next()
.unwrap()

View file

@ -6,7 +6,7 @@ fn line_match_count(line: &str) -> usize {
.split_whitespace()
.collect::<arrayvec::ArrayVec<_, 16>>();
let you_have = numbers.next().unwrap().split_whitespace();
let you_have = numbers.next().unwrap().split_whitespace();
you_have
.filter(|have| winning.iter().any(|w| w == have))