diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-12-25 17:56:34 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-12-25 17:56:34 +0100 |
| commit | 94d0033ed89bb5bfb6500051296892fb7cea6c29 (patch) | |
| tree | 245eac2218310c958c2df2fad5109ea4f7b2a9d9 /2023/18 | |
| parent | 6a480c4eb9c96c82a8fd3663f0fbee4d32e56f19 (diff) | |
| download | aoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.tar.gz aoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.zip | |
Small cleanup
Diffstat (limited to '2023/18')
| -rw-r--r-- | 2023/18/18b.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/2023/18/18b.c b/2023/18/18b.c index d79d4cb..7b16309 100644 --- a/2023/18/18b.c +++ b/2023/18/18b.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | I have lost my code for part one. It reused some stuff from day 10. | 2 | I have lost my code for part one. It reused some stuff from day |
| 3 | This code can be adjusted to work for part one, just change the input reading. | 3 | 10. This code can be adjusted to work for part one, just change the |
| 4 | input reading part. | ||
| 4 | */ | 5 | */ |
| 5 | 6 | ||
| 6 | #include <inttypes.h> | 7 | #include <inttypes.h> |
| @@ -57,10 +58,6 @@ int64_t overlaplen(int64_t a[], int64_t na, int64_t b[], int64_t nb) { | |||
| 57 | return ret; | 58 | return ret; |
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | int64_t linelen(int64_t a[], int64_t n) { | ||
| 61 | return overlaplen(a, n, a, n); | ||
| 62 | } | ||
| 63 | |||
| 64 | int main() { | 61 | int main() { |
| 65 | p[n++] = (point_t) {0}; | 62 | p[n++] = (point_t) {0}; |
| 66 | while ((buf = fgets(in, 50, stdin)) != NULL) { | 63 | while ((buf = fgets(in, 50, stdin)) != NULL) { |
| @@ -80,7 +77,7 @@ int main() { | |||
| 80 | if (p[i].i != p[i+1].i) { | 77 | if (p[i].i != p[i+1].i) { |
| 81 | qsort(a, ia, sizeof(int64_t), &cmp_int64); | 78 | qsort(a, ia, sizeof(int64_t), &cmp_int64); |
| 82 | ia = removedoubles(a, ia); | 79 | ia = removedoubles(a, ia); |
| 83 | t += linelen(a, ia) * (p[i+1].i - p[i].i + 1) - | 80 | t += overlaplen(a, ia, a, ia)*(p[i+1].i - p[i].i + 1) - |
| 84 | overlaplen(a, ia, olda, nolda); | 81 | overlaplen(a, ia, olda, nolda); |
| 85 | nolda = ia; | 82 | nolda = ia; |
| 86 | memcpy(olda, a, nolda * sizeof(int64_t)); | 83 | memcpy(olda, a, nolda * sizeof(int64_t)); |
