-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.rs
More file actions
17 lines (15 loc) · 527 Bytes
/
main.rs
File metadata and controls
17 lines (15 loc) · 527 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::collections::HashSet;
const REQ_FIELDS: [&'static str; 7] = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"];
pub fn main() {
println!(
"{}",
include_str!("../input.txt")
.split("\n\n")
.map(|fields| fields
.split_ascii_whitespace()
.map(|field| field.split(':').next().unwrap())
.collect::<HashSet<_>>())
.filter(|passport| REQ_FIELDS.iter().all(|item| passport.contains(item)))
.count(),
);
}