-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday11_helper.py
More file actions
62 lines (57 loc) · 1.56 KB
/
Copy pathday11_helper.py
File metadata and controls
62 lines (57 loc) · 1.56 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
alpha = map(chr, range(ord('a'), ord('z') + 1))
def increment(string):
outpt = string
current = alpha.index(string[-1])
new = ""
pos = -1
while True:
if current != 25:
new = alpha[current + 1] + new
outpt = string[:pos] + new
break
else:
new = "a" + new
pos -= 1
if pos == - 1 - len(string):
new = "a" + new
outpt = new
break
else:
current = alpha.index(string[pos])
return outpt
def has2Pairs(string):
pair1 = ""
pair2 = ""
for letter in range(len(string) - 1):
if string[letter] == pair1:
continue
if string[letter] == string[letter + 1]:
if pair1:
pair2 = string[letter]
return True
else:
pair1 = string[letter]
return False
def notConfusing(string):
confusing = "iol"
for letter in confusing:
if letter in string:
return False
return True
def checkConseq(string):
for char in range(len(string) - 2):
i = alpha.index(string[char])
j = alpha.index(string[char + 1])
k = alpha.index(string[char + 2])
if j == i + 1 and k == j + 1:
return True
return False
#NextPwd
current = "cqjxxyzz"
current = increment(current)
while True:
if has2Pairs(current) and checkConseq(current) and notConfusing(current):
print current
break
else:
current = increment(current)