2022 Day 19 Part 2
This commit is contained in:
parent
24c827bac8
commit
bcfefb5a42
1 changed files with 13 additions and 4 deletions
|
|
@ -13,7 +13,8 @@ const INPUT: &str = include_str!("../../input/day19.txt");
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let blueprints: Vec<Blueprint> = aoc::lines(INPUT).map(Blueprint::parse).collect();
|
let blueprints: Vec<Blueprint> = aoc::lines(INPUT).map(Blueprint::parse).collect();
|
||||||
println!("{}", part1(blueprints));
|
println!("{}", part1(&blueprints));
|
||||||
|
println!("{}", part2(&blueprints[..3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
@ -92,15 +93,23 @@ impl FromStr for Resource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn part1(blueprints: Vec<Blueprint>) -> u64 {
|
fn part1(blueprints: &[Blueprint]) -> u64 {
|
||||||
blueprints
|
blueprints
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
.map(|bp| bp.id() * quality(bp, 24))
|
.map(|bp| bp.id() * geodes_mined(bp, 24))
|
||||||
.sum()
|
.sum()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn quality(blueprint: Blueprint, total_minutes: u64) -> u64 {
|
fn part2(blueprints: &[Blueprint]) -> u64 {
|
||||||
|
blueprints
|
||||||
|
.iter()
|
||||||
|
.cloned()
|
||||||
|
.map(|bp| geodes_mined(bp, 32))
|
||||||
|
.product()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn geodes_mined(blueprint: Blueprint, total_minutes: u64) -> u64 {
|
||||||
dbg!(&blueprint.id);
|
dbg!(&blueprint.id);
|
||||||
|
|
||||||
let factory = Factory::new(blueprint);
|
let factory = Factory::new(blueprint);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue