aboutsummaryrefslogtreecommitdiff
path: root/src/day6pt1.rs
blob: 0ea45b703916041416b0245529be7148b0db90c5 (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
26
27
28
29
pub fn main() {
    let txt = std::fs::read_to_string("./input/day6.txt").unwrap();
    let lines: Vec<_> = txt
        .lines()
        .map(|s| {
            s.split(":")
                .collect::<Vec<_>>()
                .get(1)
                .unwrap()
                .split(" ")
                .filter(|&x| !x.is_empty())
                .map(|r| r.parse::<u32>().unwrap())
                .collect::<Vec<_>>()
        })
        .collect();

    let mut p: u32 = 1;
    for i in 0..lines[0].len() {
        let mut sum: u32 = 0;
        for j in 1..lines[0][i] {
            if (lines[0][i] - j) * j > lines[1][i] {
                sum += 1;
            }
        }
        p *= sum;
    }

    println!("{:?}", p);
}