summaryrefslogtreecommitdiff
path: root/day1/src/main.rs
blob: ed6c56ca374b4044dc3e7f48c717a69ae444deb0 (plain)
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
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;

fn main() {
    let file = File::open("input.txt").expect("File not found");
    let reader = BufReader::new(file);
    let values: Vec<i32> = reader
        .lines()
        .map(|x| x.unwrap().parse::<i32>().unwrap())
        .collect::<Vec<i32>>();
    let mut increasing: u16 = 0;

    for (index, _) in values.iter().enumerate() {
        if index == 0 {
            continue;
        }

        if values[index - 1] < values[index] {
            increasing += 1;
        }
    }

    println!("{}", increasing);
}