1
0
Fork 0

01: Solve in C and Python

This commit is contained in:
Mia Herkt 2022-12-02 03:11:23 +01:00
commit be7fa3b032
Signed by: mia
GPG Key ID: 72E154B8622EC191
3 changed files with 2263 additions and 0 deletions

2236
01/input.txt Normal file

File diff suppressed because it is too large Load Diff

21
01/solution.c Normal file
View File

@ -0,0 +1,21 @@
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char l[8];
int c, i, t, S, G = 0, E[256] = {0}, e = 0;
while (fgets(l, 8, stdin)) {
E[e] += c = atoi(l);
if (!c) e++;
}
for (i = 0; i < 3; i++, t = 0) {
for (c = 0; c <= e; c++) if (E[c] > E[t]) t = c;
G += E[t];
E[t] = 0;
if (!i) S = G;
}
printf("Silver: %d\nGold: %d\n", S, G);
}

6
01/solution.py Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env python3
import sys
res = sorted(sum(map(int, l.split("\n"))) for l in sys.stdin.read().strip().split("\n\n"))[-3:]
print(f"Silver: {res[-1]}\nGold: {sum(res)}")