Skip to content

Instantly share code, notes, and snippets.

@hbjydev
Created December 8, 2019 19:55
Show Gist options
  • Save hbjydev/9809d649f029260a4c0ad485bdddc7c3 to your computer and use it in GitHub Desktop.
Save hbjydev/9809d649f029260a4c0ad485bdddc7c3 to your computer and use it in GitHub Desktop.
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