advent-of-code/2021/day8/rust/src/main.rs

24 lines
583 B
Rust
Raw Normal View History

2021-12-08 20:15:42 +01:00
#![warn(clippy::pedantic)]
2022-12-01 18:11:59 +01:00
use rust_2021_8::{v3::unscramble, LineResult};
2021-12-08 20:15:42 +01:00
use std::io::{stdin, BufRead};
fn main() {
let result = stdin()
.lock()
.lines()
.map(|s| unscramble(&s.unwrap()))
.fold(
LineResult {
unique_digits: 0,
number: 0,
},
|a, b| LineResult {
unique_digits: a.unique_digits + b.unique_digits,
number: a.number + b.number,
},
);
println!("{}", result.unique_digits);
println!("{}", result.number);
}