Skip to content

Instantly share code, notes, and snippets.

@pixelomer
Created December 2, 2025 07:30
Show Gist options
  • Select an option

  • Save pixelomer/6a56ace6728075c6e665cf58b3f56283 to your computer and use it in GitHub Desktop.

Select an option

Save pixelomer/6a56ace6728075c6e665cf58b3f56283 to your computer and use it in GitHub Desktop.
import math
l=list(map(lambda x:list(map(int,x.split("-"))), input().split(",")))
x=0
for a in l:
d1=math.ceil(math.log10(a[0]))
d2=math.ceil(math.log10(a[1]))
for d in range(d1, d2+1):
if d%2==1: continue
k=int(10**(d/2))
if d==d1:
s=math.floor(a[0]/k)
if s<a[0]%k:
s+=1
else:
s=int(10**(d/2-1))
if d==d2:
e=math.floor(a[1]/k)
if e>a[1]%k:
e-=1
else:
e=k-1
s=int(s+s*k)
e=int(e+e*k)
r=range(s,e+1,k+1)
x+=sum(r)
print(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment