Created
December 4, 2019 05:24
-
-
Save Taminiora/08a9e1d101dcd578a404586f96d620e0 to your computer and use it in GitHub Desktop.
This file contains 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
s = 136818 | |
t = 685979 | |
def short(): | |
tot = 0 | |
for i in range(s, t): | |
x = str(i) | |
f = False | |
if x != ''.join(sorted(x)): | |
continue | |
for j in range(len(x)-1): | |
if x[j] == x[j+1]: | |
tot+=1 | |
break | |
return tot | |
def long_pr(): | |
tot = 0 | |
for i in range(s, t): | |
x = str(i) | |
f = False | |
if x != ''.join(sorted(x)): | |
continue | |
for j in range(len(x)-1): | |
if x[j] == x[j+1]: | |
if (j==0 or x[j-1] != x[j]) and (j==len(x)-2 or x[j+2] != x[j]): | |
tot+=1 | |
break | |
return tot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment