aboutsummaryrefslogtreecommitdiff
path: root/2023/14/14a.c
diff options
context:
space:
mode:
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