mirror of
https://gitlab.com/MisterBiggs/aoc2021.git
synced 2025-06-15 22:46:51 +00:00
day1 done
This commit is contained in:
parent
aa30dfc940
commit
5f1371412f
@ -3,18 +3,19 @@ use std::fs;
|
||||
fn main() {
|
||||
let input = fs::read_to_string("../input.txt").expect("Could not read file");
|
||||
|
||||
let lines: Vec<&str> = input.lines().collect();
|
||||
let lines: Vec<i32> = input.lines().map(|s| s.parse::<i32>().unwrap()).collect();
|
||||
|
||||
let mut previous: i32 = 10000;
|
||||
let mut increases = 0;
|
||||
|
||||
for line in lines.iter() {
|
||||
let current = line.parse::<i32>().unwrap();
|
||||
for i in 0..lines.len() - 2 {
|
||||
let current = lines[i..i + 3].iter().sum();
|
||||
|
||||
if previous < current {
|
||||
increases += 1;
|
||||
}
|
||||
previous = current;
|
||||
// println!("{}", current);
|
||||
}
|
||||
|
||||
println!("Increases: {}", increases);
|
||||
|
Loading…
x
Reference in New Issue
Block a user