Added Day1 Door 1 working

This commit is contained in:
Denis Urs Rudolph
2025-12-15 11:30:06 +01:00
parent be91c71f09
commit dc47f27c2a
2 changed files with 25 additions and 0 deletions

24
Day1/doorOne.py Normal file
View File

@@ -0,0 +1,24 @@
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)