From dc47f27c2ae6ee41b44e5308e7d85f16725bc3ca Mon Sep 17 00:00:00 2001 From: Denis Urs Rudolph Date: Mon, 15 Dec 2025 11:30:06 +0100 Subject: [PATCH] Added Day1 Door 1 working --- Day1/doorOne.py | 24 ++++++++++++++++++++++++ Day1/input.txt | 1 + 2 files changed, 25 insertions(+) create mode 100644 Day1/doorOne.py create mode 100644 Day1/input.txt diff --git a/Day1/doorOne.py b/Day1/doorOne.py new file mode 100644 index 0000000..cdeba86 --- /dev/null +++ b/Day1/doorOne.py @@ -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) \ No newline at end of file diff --git a/Day1/input.txt b/Day1/input.txt new file mode 100644 index 0000000..9059a60 --- /dev/null +++ b/Day1/input.txt @@ -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 \ No newline at end of file