-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.rs
More file actions
23 lines (20 loc) · 569 Bytes
/
main.rs
File metadata and controls
23 lines (20 loc) · 569 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const FIND: usize = 22406676;
pub fn main() {
let nums: Vec<usize> = include_str!("../input.txt")
.lines()
.map(|n| n.parse().unwrap())
.collect();
let (mut tail, mut head, mut tot) = (0, 1, nums[0] + nums[1]);
while tot != FIND {
while tot < FIND {
head += 1;
tot += nums[head];
}
while tot > FIND {
tot -= nums[tail];
tail += 1;
}
}
let set = &nums[tail..=head];
println!("{}", set.iter().min().unwrap() + set.iter().max().unwrap());
}