-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rs
33 lines (30 loc) · 875 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::collections::HashSet;
fn main() {
let mut part1 = 0;
let mut part2 = 0;
for s in include_str!("../in.txt").split("\n\n") {
let mut answers = HashSet::new();
for ans in s.split('\n') {
for c in ans.chars() {
answers.insert(c);
}
}
part1 += answers.len();
let mut common_answers = answers.clone();
for ans in s.split('\n') {
if ans != "" {
let mut local = HashSet::new();
for c in ans.chars() {
local.insert(c);
}
for c in answers.iter() {
if !local.contains(c) {
common_answers.remove(c);
}
}
}
}
part2 += common_answers.len();
}
dbg!(part1, part2);
}