Files
advent_of_code/2022/01/part 1 solution.py
T
2023-12-17 17:44:07 +00:00

37 lines
585 B
Python

with open(r'advent_of_code\2022\01\input.txt', 'r') as file:
input = file.read()
# print(input)
test_input = '''1000
2000
3000
4000
5000
6000
7000
8000
9000
10000'''
# Split the data into groups
groups = input.split('\n\n')
# Now, each element of `groups` is a string containing the numbers in one group
# You can further split each group into individual numbers if needed
groups = [group.split('\n') for group in groups]
print(groups)
# sum up each group
sums = [sum(int(num) for num in group) for group in groups]
print(sums)
# show only largest sum
print(max(sums))