summaryrefslogtreecommitdiff
path: root/08/src/part-1.rs
blob: e4773358d2e857a76220aa44b437823b814a6ef9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
mod bitfield;

use std::io::{BufRead};

use crate::bitfield::{Bitfield, parse_input};

pub fn main() {
    let mut stdin = std::io::stdin();
    let mut handle = stdin.lock();

    let mut count_1478 = 0;
    for line in handle.lines() {
        let (all, output) = parse_input(& line.unwrap());
        for x in output {
            let n = x.pop_count();
            if n == 2 || n == 3 || n == 4 || n == 7 {
                count_1478 += 1;
            }
        }
    }

    println!("The numbers 1, 4, 7, 8 occured {} times in the output.", count_1478);
}