27 lines
924 B
Python
27 lines
924 B
Python
count = 0
|
|
|
|
with open("input.txt", "r") as file:
|
|
for line in file:
|
|
largest1 = 0
|
|
largest2 = 0
|
|
lindex = 0
|
|
print(f"round 1 for line: {line.strip()}")
|
|
for i in range(len(line.strip()) - 1):
|
|
print(f"Comparing {line[i]} and {largest1}")
|
|
if int(line[i]) > largest1:
|
|
print(f"New largest found: {line[i]} at index {i}")
|
|
largest1 = int(line[i])
|
|
lindex = i
|
|
|
|
count += largest1 * 10
|
|
print(f"Largest after round 1: {largest1} at index {lindex}")
|
|
print(f"round 2 for line: {line.strip()}")
|
|
for i in range(lindex + 1, len(line.strip())):
|
|
print(f"Comparing {line[i]} and {largest2}")
|
|
if int(line[i]) > largest2:
|
|
largest2 = int(line[i])
|
|
|
|
print(f"Largest after round 2: {largest1 * 10} + {largest2}")
|
|
count += largest2
|
|
|
|
print(count) |