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)
|
||||
1
Day1/input.txt
Normal file
1
Day1/input.txt
Normal file
@@ -0,0 +1 @@
|
||||
975119-1004307,35171358-35313940,6258659887-6258804661,737649-837633,85745820-85956280,9627354-9679470,2327309144-2327509647,301168-351545,537261-631588,364281214-364453549,9563727253-9563879587,3680-9127,388369417-388406569,6677501-6752949,650804-678722,3314531-3365076,1052-2547,24134-68316,8888820274-8888998305,82614-107458,456819-529037,358216-389777,24222539-24266446,874565-916752,3886244-3960191,25-110,9696951376-9696996784,171-671,5656545867-5656605587,75795017-75865731,1-16,181025-232078
|
||||
Reference in New Issue
Block a user