1234567891011121314151617181920212223242526 |
- # Python 3.7
-
- def main():
- rangeStart = 109165
- rangeEnd = 576723
- count = 0
- for pw in range(rangeStart, rangeEnd):
- count += validatePassword(pw)
- print(count)
-
- def validatePassword(pw):
- pwStr = str(pw)
- # does it have a doubled digit
- # does it have a descending digit
- c, d = 0, 0
- for i in range(1, len(pwStr)):
- if pwStr[i-1] == pwStr[i]:
- c = 1
- if int(pwStr[i]) < int(pwStr[i-1]):
- d = 1
- if c == 0 or d == 1:
- return 0
- return 1
-
- if __name__ == "__main__":
- main()
|