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/06 | |
| parent | 6a480c4eb9c96c82a8fd3663f0fbee4d32e56f19 (diff) | |
| download | aoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.tar.gz aoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.zip | |
Small cleanup
Diffstat (limited to '2023/06')
| -rw-r--r-- | 2023/06/6a.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/2023/06/6a.c b/2023/06/6a.c index 25a85e5..b3c0ba1 100644 --- a/2023/06/6a.c +++ b/2023/06/6a.c | |||
| @@ -2,30 +2,24 @@ | |||
| 2 | 2 | ||
| 3 | #include <inttypes.h> | 3 | #include <inttypes.h> |
| 4 | #include <math.h> | 4 | #include <math.h> |
| 5 | #include <stdbool.h> | ||
| 6 | #include <stdio.h> | 5 | #include <stdio.h> |
| 7 | #include <stdlib.h> | 6 | #include <stdlib.h> |
| 8 | #include <string.h> | ||
| 9 | 7 | ||
| 10 | #define N 100000 | 8 | #define N 100000 |
| 11 | 9 | #define ISNUM(c) (c >= '0' && c <= '9') | |
| 12 | #define MIN(a, b) ((a)<(b)?(a):(b)) | ||
| 13 | #define MAX(a, b) ((a)>(b)?(a):(b)) | ||
| 14 | |||
| 15 | bool isnum(char c) { return c >= '0' && c <= '9'; } | ||
| 16 | 10 | ||
| 17 | int64_t readl(int64_t nums[], char *buf) { | 11 | int64_t readl(int64_t nums[], char *buf) { |
| 18 | int64_t i; | 12 | int64_t i; |
| 19 | for (i = 0; *buf; buf++) { | 13 | for (i = 0; *buf; buf++) { |
| 20 | if (!isnum(*buf)) continue; | 14 | if (!ISNUM(*buf)) continue; |
| 21 | nums[i++] = atoll(buf); | 15 | nums[i++] = atoll(buf); |
| 22 | while (isnum(*buf)) buf++; | 16 | while (ISNUM(*buf)) buf++; |
| 23 | } | 17 | } |
| 24 | return i; | 18 | return i; |
| 25 | } | 19 | } |
| 26 | 20 | ||
| 27 | int main() { | 21 | int main() { |
| 28 | char line[N], clean[N]; | 22 | char line[N]; |
| 29 | int64_t i, n, p, D, x1, x2, t[N], d[N]; | 23 | int64_t i, n, p, D, x1, x2, t[N], d[N]; |
| 30 | 24 | ||
| 31 | n = readl(t, fgets(line, N, stdin)); | 25 | n = readl(t, fgets(line, N, stdin)); |
