1
0
Fork 0

day(04): use new parsing function

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2023-12-04 11:00:59 +01:00
parent 153f02a831
commit a13721bcb5
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -15,19 +15,10 @@ impl FromStr for Card {
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut parts = s.split(':').nth(1).unwrap().split('|');
let (winning, draw) = (parts.next().unwrap(), parts.next().unwrap());
let winning = parts
.next()
.unwrap()
.split_ascii_whitespace()
.map(|n| n.parse().unwrap())
.collect();
let draw = parts
.next()
.unwrap()
.split_ascii_whitespace()
.map(|n| n.parse().unwrap())
.collect();
let winning: HashSet<i32> = parse_ws_separated(winning);
let draw: Vec<i32> = parse_ws_separated(draw);
Ok(Card { winning, draw })
}