From a2d928fe2647e4b80d87731417407f1533b8e4a4 Mon Sep 17 00:00:00 2001 From: Adam Spragg Date: Sat, 31 Dec 2022 15:18:30 +0000 Subject: Puzzle 19: Use int instead of long for material amounts/robots Drops time by about 20% on 20-round test data (6.6s -> 5.4s) --- 19.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to '19.c') diff --git a/19.c b/19.c index f7c950e..4e1cfb3 100644 --- a/19.c +++ b/19.c @@ -43,13 +43,13 @@ blueprint_ctor(struct blueprint * b, int id, int ore_ore, int clay_ore, struct material { - long amount; - long robots; + int amount; + int robots; }; void -material_ctor(struct material * m, long amount, long robots) +material_ctor(struct material * m, int amount, int robots) { m->amount = amount; m->robots = robots; @@ -194,7 +194,7 @@ inventory_build_basic(struct inventory * i, struct blueprint const * b, int rema inventory_tick(i); - fprintf(stderr, "Blueprint %d tick %d, ore: %ld/%ld, clay %ld/%ld, bsdn %ld/%ld, geod %ld/%ld\n", + fprintf(stderr, "Blueprint %d tick %d, ore: %d/%d, clay %d/%d, bsdn %d/%d, geod %d/%d\n", b->id, t + 1, i->ore.amount, i->ore.robots, i->clay.amount, i->clay.robots, @@ -333,7 +333,7 @@ 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 %ld/%ld, clay %ld/%ld, bsdn %ld/%ld, geod %ld/%ld\n", + fprintf(stdout, "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, @@ -346,7 +346,7 @@ main(int argc, char ** argv) return -1; } - printf("Blueprint %d geodes = %ld\n", b.id, i.geod.amount); + printf("Blueprint %d geodes = %d\n", b.id, i.geod.amount); } regfree(&reblueprint); -- cgit v1.2.1