summaryrefslogtreecommitdiff
path: root/2025/aoc2025-d02.py
diff options
context:
space:
mode:
authorbthink <bthink@fake.com>2025-12-07 15:59:37 +0100
committerbthink <bthink@fake.com>2025-12-07 15:59:37 +0100
commited395fe7a7fd68f6db4ea94de8fdcdcb0fac5179 (patch)
tree68048caf0328d39083e107cb19b989001389527c /2025/aoc2025-d02.py
parentf6ff66ea2da1f30303f17a2dac341411fb325881 (diff)
first week of AOC 2025
Diffstat (limited to '2025/aoc2025-d02.py')
-rw-r--r--2025/aoc2025-d02.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/2025/aoc2025-d02.py b/2025/aoc2025-d02.py
new file mode 100644
index 0000000..a35e776
--- /dev/null
+++ b/2025/aoc2025-d02.py
@@ -0,0 +1,26 @@
+#advent of code 2025
+#day 02
+
+part1=0;
+part2=0;
+PuzzleInput=open("02.in","r").read();
+for IDrange in PuzzleInput.split(","):
+ IDs=[int(val) for val in IDrange.split("-")];
+ for num in range(IDs[0],IDs[1]+1):
+ strnum=str(num);
+ numlen=len(strnum);
+ half=numlen//2;
+ for step in range(half,0,-1):
+ sublist=[];
+ i=0;
+ while i < numlen:
+ substring=strnum[i:i+step];
+ sublist.append(substring);
+ i+=step;
+ subset=set(sublist);
+ if len(subset)==1 and sublist.count(sublist[0])==len(sublist):
+ if step==half and len(sublist)==2: part1+=num;
+ part2+=num;
+ break;
+print("part 1",part1);
+print("part 2",part2);