Files
AdventOfCode2025/Day1/doorOne.py
2025-12-15 11:30:06 +01:00

24 lines
620 B
Python

file = open('/Users/mastermito/Dev/AdventOfCode/Day1/input.txt', 'r')
sum = 0
lines = file.readlines()
ranges = lines[0].strip().split(',')
for r in ranges:
bounds = r.split('-')
length = bounds[0].__len__()
startPattern = bounds[0][:length//2];
if startPattern == '':
startPattern = '1'
lower = int(bounds[0])
upper = int(bounds[1])
checkID = 0
while checkID <= upper:
checkID = int(startPattern + startPattern)
if checkID >= lower and checkID <= upper:
sum += checkID
startPattern = str(int(startPattern) + 1)
print('Sum is: ', sum)