aboutsummaryrefslogtreecommitdiff
path: root/2023/04/4b.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/4b.c
parent6a480c4eb9c96c82a8fd3663f0fbee4d32e56f19 (diff)
downloadaoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.tar.gz
aoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.zip
Small cleanup
Diffstat (limited to '2023/04/4b.c')
-rw-r--r--2023/04/4b.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/2023/04/4b.c b/2023/04/4b.c
index c122f8b..4529ff7 100644
--- a/2023/04/4b.c
+++ b/2023/04/4b.c
@@ -1,11 +1,9 @@
1#include <stdbool.h>
2#include <stdio.h> 1#include <stdio.h>
3#include <stdlib.h> 2#include <stdlib.h>
4#include <string.h> 3#include <string.h>
5 4
6#define N 1000 5#define N 1000
7 6#define ISNUM(c) (c >= '0' && c <= '9')
8bool isnum(char c) { return c >= '0' && c <= '9'; }
9 7
10int main() { 8int main() {
11 char *buf, line[N]; 9 char *buf, line[N];
@@ -19,15 +17,15 @@ int main() {
19 while (*buf != ':') buf++; 17 while (*buf != ':') buf++;
20 while (*buf != '|') { 18 while (*buf != '|') {
21 buf++; 19 buf++;
22 if (!isnum(*buf)) continue; 20 if (!ISNUM(*buf)) continue;
23 w[nw++] = atoi(buf); 21 w[nw++] = atoi(buf);
24 while (isnum(*buf)) buf++; 22 while (ISNUM(*buf)) buf++;
25 } 23 }
26 while (*buf != '\n') { 24 while (*buf != '\n') {
27 buf++; 25 buf++;
28 if (!isnum(*buf)) continue; 26 if (!ISNUM(*buf)) continue;
29 r[nr++] = atoi(buf); 27 r[nr++] = atoi(buf);
30 while (isnum(*buf)) buf++; 28 while (ISNUM(*buf)) buf++;
31 } 29 }
32 for (x = 0, i = 0; i < nr; i++) { 30 for (x = 0, i = 0; i < nr; i++) {
33 for (j = 0; j < nw; j++) { 31 for (j = 0; j < nw; j++) {

Generated with cgit - Back to sebastiano.tronto.net