16 lines
526 B
Python
16 lines
526 B
Python
with open(r'day3/input.txt', 'r') as input:
|
|
lines = input.read().split('\n')[:-1]
|
|
|
|
|
|
sum = 0
|
|
|
|
for line in lines:
|
|
# Transforming line to array of digits
|
|
numbers = list(map(lambda x: int(x), list(line)))
|
|
# Since the first digis is the most important, we can chose the best (careful to leave a single digit at the end to leave a second choice!)
|
|
best1 = max(numbers[:-1])
|
|
besti = numbers.index(best1) # first occurence of best digit
|
|
best2 = max(numbers[besti+1:])
|
|
sum += best1*10+best2
|
|
|
|
print(sum)
|