Day 19, part 2

This commit is contained in:
jazzpi 2022-12-21 13:44:58 +01:00
parent ab870a881e
commit f825de9426
1 changed files with 27 additions and 0 deletions

27
src/bin/d19p2.rs Normal file
View File

@ -0,0 +1,27 @@
use std::thread;
use aoc22::{day19, util};
const MINUTES: usize = 32;
const MAX_BLUEPRINTS: usize = 3;
pub fn main() {
let blueprints = day19::parse_blueprints(&util::parse_input());
assert!(blueprints.len() > 0);
let mut handles = Vec::new();
for blueprint in blueprints.iter().take(MAX_BLUEPRINTS) {
let blueprint = blueprint.clone();
handles.push(thread::spawn(move || {
day19::max_geodes(MINUTES, &blueprint)
}));
}
let mut prod = 1;
for handle in handles {
let max = handle.join().unwrap();
prod *= max;
}
println!("Product of geodes: {}", prod);
}