-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.rs
More file actions
22 lines (21 loc) · 509 Bytes
/
main.rs
File metadata and controls
22 lines (21 loc) · 509 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
pub fn main() {
let mut nums: Vec<usize> = include_str!("../input.txt")
.lines()
.map(|n| n.parse().unwrap())
.collect();
nums.sort_unstable();
println!(
"{}",
2 * nums
.windows(2)
.collect::<Vec<_>>()
.split(|n| n[1] - n[0] == 3)
.map(|n| match n.len() {
4 => 7,
3 => 4,
2 => 2,
_ => 1,
})
.product::<usize>()
);
}