aboutsummaryrefslogtreecommitdiff
path: root/src/day14pt1.rs
blob: 9b68f62436af1798bad9be9057ba7efdc97d4213 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
pub fn main() {
    let txt = std::fs::read_to_string("./input/day14.txt").unwrap();
    let input = txt
        .lines()
        .map(|s| s.chars().collect::<Vec<char>>())
        .collect::<Vec<Vec<char>>>();

    let mut sum: u64 = 0;

    for j in 0..input[0].len() {
        let mut off: u64 = 0;
        for i in 0..input.len() {
            if input[i][j] == 'O' {
                sum += input.len() as u64 - off;
                off += 1;
            } else if input[i][j] == '#' {
                off = (i + 1) as u64;
            }
        }
    }

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