summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Spragg <adam@spra.gg>2022-12-31 15:44:09 +0000
committerAdam Spragg <adam@spra.gg>2022-12-31 15:44:09 +0000
commitbfecc1b0323c3c3741840e392999b674ac3576f6 (patch)
tree1999f67a323f3adabf1cbddbd42716b68984e31d
parentd277dca9e238b938906e1ea942b1d4d2dd0910ec (diff)
Puzzle 19: Solve part 1 (yay!)
Just generate the output needed by the puzzle.
-rw-r--r--19.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/19.c b/19.c
index 61ac737..d2907c2 100644
--- a/19.c
+++ b/19.c
@@ -293,7 +293,7 @@ main(int argc, char ** argv)
{
int rounds = 24;
char const * build = "basic";
- int i;
+ int quality = 0, i;
regex_t reblueprint;
char buf[BUFSIZ];
@@ -351,12 +351,14 @@ main(int argc, char ** argv)
else if (strcmp(build, "exhaustive") == 0) {
exhaustive_iter = 0;
inventory_build_exhaustive(&i, &b, rounds);
- fprintf(stdout, "Blueprint %d, iterations %ld, ore %d/%d, clay %d/%d, bsdn %d/%d, geod %d/%d\n",
+#if 0
+ fprintf(stderr, "Blueprint %d, iterations %ld, ore %d/%d, clay %d/%d, bsdn %d/%d, geod %d/%d\n",
b.id, exhaustive_iter,
i.ore.amount, i.ore.robots,
i.clay.amount, i.clay.robots,
i.bsdn.amount, i.bsdn.robots,
i.geod.amount, i.geod.robots);
+#endif
}
else {
fprintf(stderr, "Unknown build strategy: %s\n", build);
@@ -364,9 +366,14 @@ main(int argc, char ** argv)
return -1;
}
- printf("Blueprint %d geodes = %d\n", b.id, i.geod.amount);
+ quality += b.id * i.geod.amount;
+#if 0
+ fprintf(stderr, "Blueprint %d geodes = %d\n", b.id, i.geod.amount);
+#endif
}
+ printf("Total quality level = %d\n", quality);
+
regfree(&reblueprint);
return 0;