diff options
-rw-r--r-- | 19.c | 40 |
1 files changed, 37 insertions, 3 deletions
@@ -303,18 +303,41 @@ int main(int argc, char ** argv) { int rounds = 24; - char const * build = "exhaustive"; + char const * build = "exhaustive", * output = "quality"; int quality = 0, i; + long product = 1; regex_t reblueprint; char buf[BUFSIZ]; - while ((i = getopt(argc, argv, "b:r:")) != -1) + while ((i = getopt(argc, argv, "p:b:o:r:")) != -1) { switch (i) { + case 'p': + switch (atoi(optarg)) { + case 1: + rounds = 24; + output = "quality"; + break; + + case 2: + rounds = 32; + output = "product"; + break; + + default: + fprintf(stderr, "Unexpected puzzle part: %s\n", optarg); + return -1; + } + break; + case 'b': build = optarg; break; + case 'o': + output = optarg; + break; + case 'r': rounds = atoi(optarg); break; @@ -378,12 +401,23 @@ main(int argc, char ** argv) } quality += b.id * i.geod.amount; + product *= 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); + if (strcmp(output, "quality") == 0) { + printf("Total quality level = %d\n", quality); + } + else if (strcmp(output, "product") == 0) { + printf("Total geode product = %ld\n", product); + } + else { + fprintf(stderr, "Unknown output type: %s\n", output); + regfree(&reblueprint); + return -1; + } regfree(&reblueprint); |