diff options
Diffstat (limited to '19.c')
-rw-r--r-- | 19.c | 42 |
1 files changed, 21 insertions, 21 deletions
@@ -149,19 +149,30 @@ inventory_build(struct inventory * i, struct blueprint const * b, enum MATERIAL void inventory_build_basic(struct inventory * i, struct blueprint const * b, int remaining) { - (void) remaining; + int t; - while (inventory_build(i, b, GEOD) == 0) - ; + for (t = 0; t < remaining; ++t) { + while (inventory_build(i, b, GEOD) == 0) + ; - while (inventory_build(i, b, BSDN) == 0) - ; + while (inventory_build(i, b, BSDN) == 0) + ; - while (inventory_build(i, b, CLAY) == 0) - ; + while (inventory_build(i, b, CLAY) == 0) + ; - while (inventory_build(i, b, ORE) == 0) - ; + while (inventory_build(i, b, ORE) == 0) + ; + + inventory_tick(i); + + fprintf(stderr, "Blueprint %d tick %d, ore: %ld/%ld, clay %ld/%ld, bsdn %ld/%ld, geod %ld/%ld\n", + b->id, t + 1, + i->ore.amount, i->ore.robots, + i->clay.amount, i->clay.robots, + i->bsdn.amount, i->bsdn.robots, + i->bsdn.amount, i->bsdn.robots); + } } @@ -184,7 +195,6 @@ main() while (fgets(buf, sizeof(buf), stdin)) { regmatch_t rematch[8]; - int t; struct blueprint b; struct inventory i; @@ -203,18 +213,8 @@ main() atoi(buf + rematch[7].rm_so)); inventory_init(&i); - for (t = 0; t < 24; ++t) { - inventory_build_basic(&i, &b, 24 - t); - inventory_tick(&i); - - fprintf(stderr, "Blueprint %d tick %d, ore: %ld/%ld, clay %ld/%ld, bsdn %ld/%ld, geod %ld/%ld\n", - b.id, t + 1, - i.ore.amount, i.ore.robots, - i.clay.amount, i.clay.robots, - i.bsdn.amount, i.bsdn.robots, - i.bsdn.amount, i.bsdn.robots); - } + inventory_build_basic(&i, &b, 24); printf("Blueprint %d geodes = %ld\n", b.id, i.geod.amount); } |