Created
December 8, 2019 19:55
-
-
Save hbjydev/9809d649f029260a4c0ad485bdddc7c3 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
input = "347312-805915" | |
yes = [] | |
def check_adjacent_digits(password: str) -> bool: | |
yessir = [] | |
for i in range(0, 4): | |
if password[i] == password[i + 1]: | |
if len(password) > (i + 1): | |
if password[i] != password[i + 2]: | |
yessir.append('yep') | |
if len(yessir) > 0: | |
return True | |
return False | |
def check_not_smaller(password: str) -> bool: | |
yessir = [] | |
for i in range(0, 5): | |
if int(password[i]) <= int(password[i + 1]): | |
yessir.append('yes') | |
if len(yessir) == 5: | |
return True | |
return False | |
def is_valid_pass(password: str) -> bool: | |
if len(password) == 6: | |
if int(password) >= 347312: | |
if int(password) <= 805915: | |
if check_adjacent_digits(password): | |
if check_not_smaller(password): | |
return True | |
return False | |
for i in range(int(input.split('-')[0]), int(input.split('-')[1])): | |
string = str(i) | |
if is_valid_pass(string): | |
yes.append(string) | |
print(len(yes)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment