diff options
Diffstat (limited to '2025/aoc2025-d02.py')
| -rw-r--r-- | 2025/aoc2025-d02.py | 26 |
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); |
