You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
570 B
Rust
28 lines
570 B
Rust
3 years ago
|
use itertools::Itertools;
|
||
|
use std::io::stdin;
|
||
|
use std::io::BufRead;
|
||
|
|
||
|
fn main() {
|
||
|
let mut prev: Option<i32> = None;
|
||
|
let mut increased = 0;
|
||
|
for (a, b, c) in stdin()
|
||
|
.lock()
|
||
|
.lines()
|
||
|
.map(|line| line.unwrap().parse::<i32>().unwrap())
|
||
|
.tuple_windows()
|
||
|
{
|
||
|
let sum = a + b + c;
|
||
|
match prev {
|
||
|
Some(prev) => {
|
||
|
if sum > prev {
|
||
|
increased += 1
|
||
|
}
|
||
|
}
|
||
|
_ => (),
|
||
|
}
|
||
|
prev = Some(sum)
|
||
|
}
|
||
|
|
||
|
println!("{}", increased)
|
||
|
}
|