Created
December 2, 2025 07:52
-
-
Save pixelomer/b2bd8d25ba60c497fcd1d978e0d90aa4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| l=list(map(lambda x:list(map(int,x.split("-"))), input().split(","))) | |
| def finddup(s, e, d, l): | |
| if d%l!=0: return range(0,0) | |
| a=0 | |
| for i in range(0, d, l): | |
| a+=10**i | |
| s=math.ceil(s/a)*a | |
| e=math.floor(e/a)*a | |
| return range(s, e+1, a) | |
| def solve(part2): | |
| x=0 | |
| for a in l: | |
| d1=math.ceil(math.log10(a[0])) | |
| d2=math.ceil(math.log10(a[1])) | |
| ids=set() | |
| for d in range(d1, d2+1): | |
| if part2: | |
| r = range(1,d) | |
| elif d%2==1: | |
| continue | |
| else: | |
| r = [int(d/2)] | |
| if d==d1: s=a[0] | |
| else: s=10**(d-1) | |
| if d==d2: e=a[1] | |
| else: e=10**d-1 | |
| for i in r: | |
| r=finddup(s, e, d, i) | |
| ids.update(r) | |
| x+=sum(ids) | |
| return x | |
| print(solve(part2=True)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment