-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04-2.py
More file actions
executable file
·44 lines (40 loc) · 1.53 KB
/
Copy path04-2.py
File metadata and controls
executable file
·44 lines (40 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
input = [307237, 769058]
def validatePassword(password, input):
pass_string = str(password)
# check if length = 6 digits
# if not len(pass_string) == 6:
# return False
# find adjacent digits pair
pair_found = False
if pass_string[0] == pass_string[1] and pass_string[2] != pass_string[0]:
pair_found = True
elif pass_string[1] == pass_string[2] and pass_string[0] != pass_string[1] and pass_string[3] != pass_string[1]:
pair_found = True
elif pass_string[2] == pass_string[3] and pass_string[1] != pass_string[2] and pass_string[4] != pass_string[2]:
pair_found = True
elif pass_string[3] == pass_string[4] and pass_string[2] != pass_string[3] and pass_string[5] != pass_string[3]:
pair_found = True
elif pass_string[4] == pass_string[5] and pass_string[3] != pass_string[4]:
pair_found = True
if not pair_found:
return False
# check if numbers never decrease
if int(pass_string[0]) > int(pass_string[1]):
return False
elif int(pass_string[1]) > int(pass_string[2]):
return False
elif int(pass_string[2]) > int(pass_string[3]):
return False
elif int(pass_string[3]) > int(pass_string[4]):
return False
elif int(pass_string[4]) > int(pass_string[5]):
return False
return True
if __name__ == "__main__":
result = []
for i in range(input[0], input[1] + 1):
if validatePassword(i, input):
result.append(i)
print(result)
print(len(result))