summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Spragg <adam@spra.gg>2022-12-31 15:18:30 +0000
committerAdam Spragg <adam@spra.gg>2022-12-31 15:18:30 +0000
commita2d928fe2647e4b80d87731417407f1533b8e4a4 (patch)
tree9d6b512be900aadead13c180075ecd5f20c95251
parent24016229c1d1999f255d69c42cdcb96a7e8d0f94 (diff)
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)
-rw-r--r--19.c12
1 files changed, 6 insertions, 6 deletions
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);