-
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Hi Tim, I admire your elegant, idiomatic solutions, however sometimes you got lucky.
For example in day04 parsing at
advent-of-code-2020/day04b/src/main.rs
Line 26 in 0dd2865
"byr" => value.parse::<usize>().unwrap().wrapping_sub(1920) <= 82, |
you would panic due to calling unwrap()
in case the token following byr:
is not a sequence of 4 digits (which the task description asked us to check):
https://adventofcode.com/2020/day/4
You can continue to ignore the cid field, but each other field has strict rules about what values are valid for automatic validation:
byr (Birth Year) - four digits; at least 1920 and at most 2002.
Example input:
hgt:157cm byr:hugo ecl:grn iyr:2012
eyr:2030 hcl:#18171d pid:173cm
(Just stumbled upon your solution when trying to improve my Rust coding style to become more idiomatic and looking at other people's solutions)
Metadata
Metadata
Assignees
Labels
No labels