aboutsummaryrefslogtreecommitdiff
path: root/2023/03/3b.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/03/3b.c
parent6a480c4eb9c96c82a8fd3663f0fbee4d32e56f19 (diff)
downloadaoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.tar.gz
aoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.zip
Small cleanup
Diffstat (limited to '2023/03/3b.c')
-rw-r--r--2023/03/3b.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/2023/03/3b.c b/2023/03/3b.c
index 27b5b7c..9bf4c27 100644
--- a/2023/03/3b.c
+++ b/2023/03/3b.c
@@ -1,22 +1,16 @@
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 grab(char *buf) { 8int grab(char *buf) {
11 int x; 9 if (!ISNUM(*buf)) return 0;
12 10 while (ISNUM(*buf)) buf--;
13 if (!isnum(*buf))
14 return 0;
15
16 while (isnum(*buf)) buf--;
17 buf++; 11 buf++;
18 x = atoi(buf); 12 int x = atoi(buf);
19 while (isnum(*buf)) *buf++ = '.'; 13 while (ISNUM(*buf)) *buf++ = '.';
20 14
21 return x; 15 return x;
22} 16}

Generated with cgit - Back to sebastiano.tronto.net