working on 2022 day 1 & 2

This commit is contained in:
Jake Pullen
2023-12-01 14:22:38 +00:00
parent 803de69aaa
commit 84fb42f207
9 changed files with 5048 additions and 15 deletions
+33 -2
View File
@@ -1,6 +1,37 @@
import os
with open(r'advent_of_code\2022\day_1\input.txt', 'r') as file:
input = file.read()
print(input)
# 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))