diff options
author | Adam Spragg <adam@spra.gg> | 2022-12-17 21:10:51 +0000 |
---|---|---|
committer | Adam Spragg <adam@spra.gg> | 2022-12-17 21:10:51 +0000 |
commit | e906454afbff5ccf9771758d335010d5fb2ab48a (patch) | |
tree | 100b5141b30d0ca91210b98f0ea4fbb69fdfebb8 /16.c | |
parent | be31c082ce6ec6bf3ed5d4c4f6c8f460045a8757 (diff) |
Allow variable time until eruption
Diffstat (limited to '16.c')
-rw-r--r-- | 16.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -221,7 +221,7 @@ valve_distance(struct valve * valves, int nvalves, int * dists, struct valve con int main(int argc, char ** argv) { - int debug = 0, i; + int debug = 0, eruption = 30, i; regex_t valvein; regmatch_t rmvalve[4]; char buf[BUFSIZ]; @@ -236,12 +236,17 @@ main(int argc, char ** argv) return -1; } - while ((i = getopt(argc, argv, "d")) != -1) { + while ((i = getopt(argc, argv, "dt:")) != -1) { switch (i) { case 'd': debug = 1; break; + case 't': + // 'time' is taken by time(3), hence 'eruption' + eruption = atoi(optarg); + break; + default: return -1; } @@ -304,7 +309,7 @@ main(int argc, char ** argv) qsort(path + 1, nflows, sizeof(struct valve *), ptrcmp); do { struct valve ** pv; - int flow = 0, minutes = 30; + int flow = 0, minutes = eruption; // Calculate the flow of this permutation. for (pv = path + 1; pv < path + 1 + nflows && minutes > 0; ++pv) { |