diff options
author | dzwdz | 2022-12-19 20:57:40 +0100 |
---|---|---|
committer | dzwdz | 2022-12-19 20:57:40 +0100 |
commit | 8cf452005e0c87ecb9cb98500f9dee2b2e479baa (patch) | |
tree | a747af22a472b37587d059c01fc6988a1026be67 | |
parent | af06f4109869e1f8942eb033144d01a26b737391 (diff) |
day 19 part 2
-rw-r--r-- | 22.19/main.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
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 <algorithm> #include <cstdio> #include <optional> @@ -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); } |