Added Day1 Door 1 working
This commit is contained in:
24
Day1/doorOne.py
Normal file
24
Day1/doorOne.py
Normal 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)
|
||||
Reference in New Issue
Block a user