diff options
Diffstat (limited to '22.19/main.cpp')
-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); } |