diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-12-19 15:54:12 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-12-19 15:54:12 +0100 |
| commit | 1f75d7c9ebec207c8193754792076dc66eba9713 (patch) | |
| tree | 48556a419f050153513cd5a3b8a4a6e125ba2c45 /2023/15/15a.c | |
| parent | 83adb5e4215a25d17cfc11b4dbf10cf20c418c20 (diff) | |
| download | aoc-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.c | 21 |
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 | |||
| 5 | char *b, line[N]; | ||
| 6 | int c, s; | ||
| 7 | |||
| 8 | int 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 | } | ||
