diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-12-14 19:22:23 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-12-14 19:22:23 +0100 |
| commit | 83adb5e4215a25d17cfc11b4dbf10cf20c418c20 (patch) | |
| tree | 03dacc46ec973184742d4f112896413c87269b9b /2023/14/14a.c | |
| parent | b50110f5d370be071f9f1ce5ef4e1a7fdf41ce58 (diff) | |
| download | aoc-83adb5e4215a25d17cfc11b4dbf10cf20c418c20.tar.gz aoc-83adb5e4215a25d17cfc11b4dbf10cf20c418c20.zip | |
Added solution for 14
Diffstat (limited to '2023/14/14a.c')
| -rw-r--r-- | 2023/14/14a.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/2023/14/14a.c b/2023/14/14a.c new file mode 100644 index 0000000..e56a409 --- /dev/null +++ b/2023/14/14a.c | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | |||
| 3 | #define N 102 | ||
| 4 | |||
| 5 | char line[N]; | ||
| 6 | int i, j, t, s[N], r[N]; | ||
| 7 | |||
| 8 | int main() { | ||
| 9 | for (i = 0; fgets(line, N, stdin) != NULL; i++) { | ||
| 10 | for (j = 0; line[j] != '\n'; j++) { | ||
| 11 | if (line[j] == '#') s[j] = i+1; | ||
| 12 | if (line[j] == 'O') r[s[j]++]++; | ||
| 13 | } | ||
| 14 | } | ||
| 15 | for (j = 0; j < i; j++) | ||
| 16 | t += r[j] * (i-j); | ||
| 17 | |||
| 18 | printf("%d\n", t); | ||
| 19 | return 0; | ||
| 20 | } | ||
