Add comments to solutions so far
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
total = 0
|
||||
elves = []
|
||||
|
||||
# Add each line of the input, when we hit a blank line put the current total in a list.
|
||||
with open('input.txt', 'r') as inputFile:
|
||||
for line in inputFile:
|
||||
if line == '\n':
|
||||
@@ -11,4 +12,5 @@ with open('input.txt', 'r') as inputFile:
|
||||
else:
|
||||
total += int(line)
|
||||
|
||||
# Print the largest number in the list.
|
||||
print(max(elves))
|
||||
|
@@ -3,6 +3,7 @@
|
||||
total = 0
|
||||
elves = []
|
||||
|
||||
# Add each line of the input, when we hit a blank line put the current total in a list.
|
||||
with open('input.txt', 'r') as inputFile:
|
||||
for line in inputFile:
|
||||
if line == '\n':
|
||||
@@ -11,9 +12,11 @@ with open('input.txt', 'r') as inputFile:
|
||||
else:
|
||||
total += int(line)
|
||||
|
||||
# Find the total of the largest three items in the list.
|
||||
topThree = 0
|
||||
for i in range(3):
|
||||
topThree += max(elves)
|
||||
elves.remove(max(elves))
|
||||
|
||||
# Print the answer.
|
||||
print(topThree)
|
||||
|
Reference in New Issue
Block a user