From 8cf452005e0c87ecb9cb98500f9dee2b2e479baa Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 19 Dec 2022 20:57:40 +0100 Subject: day 19 part 2 --- 22.19/main.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to '22.19') diff --git a/22.19/main.cpp b/22.19/main.cpp index 45985c9..d4600db 100644 --- a/22.19/main.cpp +++ b/22.19/main.cpp @@ -1,3 +1,5 @@ +/* Part two runs orders of magnitude slower. */ + #include #include #include @@ -87,9 +89,15 @@ main() "Each geode robot costs %d ore and %d obsidian. "; int id; MatMat costs = {0}; - int total = 0; + int partOne = 0; + int partTwo = 1; while (scanf(fmt, &id, &costs[Ore][Ore], &costs[Clay][Ore], &costs[Obs][Ore], &costs[Obs][Clay], &costs[Geode][Ore], &costs[Geode][Obs]) == 7) { - total += id * State{.rem=24}.best(costs); + partOne += id * State{.rem=24}.best(costs); + if (id <= 3) { + partTwo *= State{.rem=32}.best(costs); + printf("two %d\n", partTwo); + } } - printf("%d\n", total); + printf("%d\n", partOne); + printf("%d\n", partTwo); } -- cgit 1.4.1-2-gfad0