summaryrefslogtreecommitdiffstats
path: root/prog/aoc/23/1/1.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--prog/aoc/23/1/1.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/prog/aoc/23/1/1.c b/prog/aoc/23/1/1.c
new file mode 100644
index 0000000..ce0f01f
--- /dev/null
+++ b/prog/aoc/23/1/1.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+int main (void) {
+ int c = getchar();
+ int prev = -1;
+ int sum = 0;
+ while (!ferror(stdin) && !feof(stdin)) {
+ if (c == '\n') {
+ sum += prev;
+ prev = -1;
+ }
+ if (c <= '9' && c >= '0') {
+ if (prev == -1)
+ sum += 10*(c-'0');
+ prev = c-'0';
+ }
+ c = getchar();
+
+ }
+ printf("%d\n", sum);
+}