48 lines
714 B
Python
48 lines
714 B
Python
import re
|
|
|
|
input = "cqjxjnds"
|
|
|
|
def match(pattern, string):
|
|
return re.search(pattern, string) != None
|
|
|
|
def rule1(input):
|
|
matched = 0
|
|
last = '-'
|
|
|
|
for c in input:
|
|
if ord(c) == ord(last) + 1:
|
|
matched += 1
|
|
if matched == 3:
|
|
return True
|
|
else:
|
|
matched = 1
|
|
|
|
last = c
|
|
|
|
|
|
return False
|
|
|
|
|
|
def increment(input):
|
|
res = ""
|
|
carry = 1
|
|
|
|
for c in reversed(input):
|
|
if carry != 0:
|
|
if c=='z':
|
|
c = chr(ord('a'))
|
|
carry = carry
|
|
else:
|
|
c = chr(ord(c)+carry)
|
|
carry = 0
|
|
res = c + res
|
|
|
|
return res
|
|
|
|
|
|
for i in range(10):
|
|
while not (rule1(input) and match(r"(.)\1.*(.)\2", input) and not match(r"i|o|l", input)):
|
|
input = increment(input)
|
|
print(input)
|
|
input = increment(input)
|