Day 19, part 1

This commit is contained in:
jazzpi
2022-12-21 13:39:43 +01:00
parent 813c9f0612
commit ab870a881e
3 changed files with 265 additions and 0 deletions

26
src/bin/d19p1.rs Normal file
View File

@ -0,0 +1,26 @@
use std::thread;
use aoc22::{day19, util};
const MINUTES: usize = 24;
pub fn main() {
let blueprints = day19::parse_blueprints(&util::parse_input());
let mut handles = Vec::new();
for (i, blueprint) in blueprints.iter().enumerate() {
let blueprint = blueprint.clone();
handles.push((
i,
thread::spawn(move || day19::max_geodes(MINUTES, &blueprint)),
));
}
let mut sum = 0;
for (i, handle) in handles {
let max = handle.join().unwrap();
sum += (i + 1) * max;
}
println!("Sum of quality scores: {}", sum);
}