From 1f75d7c9ebec207c8193754792076dc66eba9713 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 19 Dec 2023 15:54:12 +0100 Subject: Added solutions for 15, 16, 17, 18 and 19 --- 2023/15/15a.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 2023/15/15a.c (limited to '2023/15/15a.c') 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 @@ +#include + +#define N 100000 + +char *b, line[N]; +int c, s; + +int main() { + fgets(line, N, stdin); + + for (b = line, c = 0, s = 0; *b; b++) { + if (*b == ',' || *b == '\n') { + s += c; + c = 0; + } else + c = (c + (int)*b) * 17 % 256; + } + + printf("%d\n", s); + return 0; +} -- cgit v1.3