aboutsummaryrefslogtreecommitdiff
path: root/2023/15/15a.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2023-12-19 15:54:12 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2023-12-19 15:54:12 +0100
commit1f75d7c9ebec207c8193754792076dc66eba9713 (patch)
tree48556a419f050153513cd5a3b8a4a6e125ba2c45 /2023/15/15a.c
parent83adb5e4215a25d17cfc11b4dbf10cf20c418c20 (diff)
downloadaoc-1f75d7c9ebec207c8193754792076dc66eba9713.tar.gz
aoc-1f75d7c9ebec207c8193754792076dc66eba9713.zip
Added solutions for 15, 16, 17, 18 and 19
Diffstat (limited to '2023/15/15a.c')
-rw-r--r--2023/15/15a.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/2023/15/15a.c b/2023/15/15a.c
new file mode 100644
index 0000000..16a8fec
--- /dev/null
+++ b/2023/15/15a.c
@@ -0,0 +1,21 @@
1#include <stdio.h>
2
3#define N 100000
4
5char *b, line[N];
6int c, s;
7
8int main() {
9 fgets(line, N, stdin);
10
11 for (b = line, c = 0, s = 0; *b; b++) {
12 if (*b == ',' || *b == '\n') {
13 s += c;
14 c = 0;
15 } else
16 c = (c + (int)*b) * 17 % 256;
17 }
18
19 printf("%d\n", s);
20 return 0;
21}

Generated with cgit - Back to sebastiano.tronto.net