aboutsummaryrefslogtreecommitdiff
path: root/2023/14/14a.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2023-12-14 19:22:23 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2023-12-14 19:22:23 +0100
commit83adb5e4215a25d17cfc11b4dbf10cf20c418c20 (patch)
tree03dacc46ec973184742d4f112896413c87269b9b /2023/14/14a.c
parentb50110f5d370be071f9f1ce5ef4e1a7fdf41ce58 (diff)
downloadaoc-83adb5e4215a25d17cfc11b4dbf10cf20c418c20.tar.gz
aoc-83adb5e4215a25d17cfc11b4dbf10cf20c418c20.zip
Added solution for 14
Diffstat (limited to '2023/14/14a.c')
-rw-r--r--2023/14/14a.c20
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
5char line[N];
6int i, j, t, s[N], r[N];
7
8int 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}

Generated with cgit - Back to sebastiano.tronto.net