就是一个回溯算法,写着玩玩
keyi = []
data = []
def whatWord():
while True:
word = input("请输入可疑字符,输入shier结束")
if word == "shier":
break
keyi.append(word)
def backtracking(keyi, start, data, count, cout_keyi):
if (start > cout_keyi-1 and not data) or start > cout_keyi:
return
if len(data) == count:
with open('pass.txt', mode="a") as f:
f.write(''.join(data))
f.write('\n')
return
for i in range(start, cout_keyi):
if keyi[i] not in data:
data.append(keyi[i])
backtracking(keyi, start, data, count, cout_keyi)
del(data[-1])
def passMaker(keyi):
count_keyi = len(keyi)
for i in range(1, count_keyi+1):
backtracking(keyi, 0, data, i, count_keyi)
whatWord()
passMaker(keyi)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)