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/01 | |
| parent | 6a480c4eb9c96c82a8fd3663f0fbee4d32e56f19 (diff) | |
| download | aoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.tar.gz aoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.zip | |
Small cleanup
Diffstat (limited to '2023/01')
| -rw-r--r-- | 2023/01/1a.c | 3 | ||||
| -rw-r--r-- | 2023/01/1b.c | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/2023/01/1a.c b/2023/01/1a.c index 0983236..229df20 100644 --- a/2023/01/1a.c +++ b/2023/01/1a.c | |||
| @@ -9,8 +9,7 @@ int main() { | |||
| 9 | sum = 0; | 9 | sum = 0; |
| 10 | while ((buf = fgets(line, N, stdin)) != NULL) { | 10 | while ((buf = fgets(line, N, stdin)) != NULL) { |
| 11 | for (first = -1; *buf; buf++) { | 11 | for (first = -1; *buf; buf++) { |
| 12 | if (*buf < '0' || *buf > '9') | 12 | if (*buf < '0' || *buf > '9') continue; |
| 13 | continue; | ||
| 14 | first = first == -1 ? *buf - '0' : first; | 13 | first = first == -1 ? *buf - '0' : first; |
| 15 | last = *buf - '0'; | 14 | last = *buf - '0'; |
| 16 | } | 15 | } |
diff --git a/2023/01/1b.c b/2023/01/1b.c index adc3da8..795571b 100644 --- a/2023/01/1b.c +++ b/2023/01/1b.c | |||
| @@ -16,8 +16,7 @@ int main() { | |||
| 16 | for (j = 1; j < 10; j++) | 16 | for (j = 1; j < 10; j++) |
| 17 | if (!strncmp(buf, nums[j], strlen(nums[j]))) | 17 | if (!strncmp(buf, nums[j], strlen(nums[j]))) |
| 18 | *buf = j + '0'; | 18 | *buf = j + '0'; |
| 19 | if (*buf < '0' || *buf > '9') | 19 | if (*buf < '0' || *buf > '9') continue; |
| 20 | continue; | ||
| 21 | first = first == -1 ? *buf - '0' : first; | 20 | first = first == -1 ? *buf - '0' : first; |
| 22 | last = *buf - '0'; | 21 | last = *buf - '0'; |
| 23 | } | 22 | } |
