Skip to content

Instantly share code, notes, and snippets.

@lavabyrd
Last active December 4, 2022 13:47
Show Gist options
  • Save lavabyrd/35f49ff8445e2870ba995ac5ef9adf00 to your computer and use it in GitHub Desktop.
Save lavabyrd/35f49ff8445e2870ba995ac5ef9adf00 to your computer and use it in GitHub Desktop.
file1 = open('input.txt', 'r')
Lines = file1.readlines()
with open('input.txt') as f:
lines = [line.rstrip() for line in f]
count = 0
elf = 1
out = {}
for i in lines:
if i:
count += int(i)
if not i:
out[elf] = count
elf += 1
count = 0
max_key = None
max_val = None
second = 0
third = 0
for key, val in out.items():
if max_val is None:
max_val = val
print("max val set to {}".format(max_val))
if val > max_val:
max_val = val
elif val > second:
second = val
elif val > third:
third = val
print(f"max value is {max_val}")
print(f"second value is {second}")
print(f"third value is {third}")
print("total {}".format(max_val + second + third))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment