aboutsummaryrefslogtreecommitdiff
path: root/2023/04/4a.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2023-12-25 17:56:34 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2023-12-25 17:56:34 +0100
commit94d0033ed89bb5bfb6500051296892fb7cea6c29 (patch)
tree245eac2218310c958c2df2fad5109ea4f7b2a9d9 /2023/04/4a.c
parent6a480c4eb9c96c82a8fd3663f0fbee4d32e56f19 (diff)
downloadaoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.tar.gz
aoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.zip
Small cleanup
Diffstat (limited to '2023/04/4a.c')
-rw-r--r--2023/04/4a.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/2023/04/4a.c b/2023/04/4a.c
index a1f6a9e..30b7b41 100644
--- a/2023/04/4a.c
+++ b/2023/04/4a.c
@@ -1,11 +1,8 @@
1#include <stdbool.h>
2#include <stdio.h> 1#include <stdio.h>
3#include <stdlib.h> 2#include <stdlib.h>
4#include <string.h>
5 3
6#define N 1000 4#define N 1000
7 5#define ISNUM(c) (c >= '0' && c <= '9')
8bool isnum(char c) { return c >= '0' && c <= '9'; }
9 6
10int main() { 7int main() {
11 char *buf, line[N]; 8 char *buf, line[N];
@@ -17,15 +14,15 @@ int main() {
17 while (*buf != ':') buf++; 14 while (*buf != ':') buf++;
18 while (*buf != '|') { 15 while (*buf != '|') {
19 buf++; 16 buf++;
20 if (!isnum(*buf)) continue; 17 if (!ISNUM(*buf)) continue;
21 w[nw++] = atoi(buf); 18 w[nw++] = atoi(buf);
22 while (isnum(*buf)) buf++; 19 while (ISNUM(*buf)) buf++;
23 } 20 }
24 while (*buf != '\n') { 21 while (*buf != '\n') {
25 buf++; 22 buf++;
26 if (!isnum(*buf)) continue; 23 if (!ISNUM(*buf)) continue;
27 r[nr++] = atoi(buf); 24 r[nr++] = atoi(buf);
28 while (isnum(*buf)) buf++; 25 while (ISNUM(*buf)) buf++;
29 } 26 }
30 for (x = 0, i = 0; i < nr; i++) { 27 for (x = 0, i = 0; i < nr; i++) {
31 for (j = 0; j < nw; j++) { 28 for (j = 0; j < nw; j++) {

Generated with cgit - Back to sebastiano.tronto.net