First three days

This commit is contained in:
2022-12-04 10:40:06 +03:00
commit 815f61f16d
8 changed files with 5242 additions and 0 deletions

2237
01/input Normal file

File diff suppressed because it is too large Load Diff

42
01/task.py Normal file
View File

@ -0,0 +1,42 @@
TEST_INPUT = '''
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
'''
TEST_ANSWER = 45000
def sum_of_group(group):
return sum((int(x) for x in group.split('\n')))
def solution(input):
groups = input.strip().split('\n\n')
print(groups)
sums = [sum_of_group(g) for g in groups]
print(sums)
top3 = list(sorted(sums))[-3:]
print(top3)
return sum(top3)
print(solution(TEST_INPUT) == TEST_ANSWER)
with open('input', 'r') as f:
i = f.read()
print(solution(i))