啦啦啦啦德玛西亚
本帖最后由 qq1151985918 于 2021-10-17 22:00 编辑{:9_227:} {:9_227:}
def isLengthEnough(s):
if 6 <= len(s) <= 20:
return True
else:
return False
def isNumIn(s):
for i in s:
if i.isdigit():
return True
else:
return False
def isLowIn(s):
for i in s:
if i.islower():
return True
else:
return False
def isCapIn(s):
for i in s:
if i.isupper():
return True
else:
return False
def isNotRepeat3(s):
for i in set(s):
if i * 3 in s:
return False
else:
return True
def allRepeat3(s):
r = []
while not isNotRepeat3(s):
for i in s:
for j in range(len(s), 2, -1):
if i * j in s:
for k in range(s.count(i * j)):
r.append(i * j)
s = s.replace(i * j, "")
break
return sorted(r, key=lambda x:len(x), reverse=True)
def chooseChar(s):
for x in allRepeat3(s[:]):
s = s.replace(x, x[:2])
return s
def run(s):
r = sum()
if r == 5:
result = 0
elif sum() == 0:
cs = chooseChar(s)
if len(cs) >= 20:
return (len(s) - 20 + (3 - r))
if len(cs) + (3 - r) >= 20:
return (len(s) - 20 + (3 - r))
allR = allRepeat3(s)
t, flg = 0, False
res1 = max()
n = 20 - len(cs)
for x in allR:
i = x[:-2]
if flg:
t += len(s) - len(cs) - len(allR[:-2])
break
elif not flg and len(i) > n:
flg = True
t += len(i) - n + (n // 3)
else:
t += len(i) // 3
res2 = max()
result = max()
elif not isLengthEnough(s):
t = max()
result = max()
elif not isNotRepeat3(s):
t = 0
for i in allRepeat3(s):
t += len(i) // 3
result = max()
else:
result = 5 - r
return result
if __name__ == "__main__":
password = input("输入密码:")
print("密码变强所需的最少步骤:", run(password))
3 5块钱。你买瓶水喝够了。
ba21 发表于 2021-4-29 21:12
3 5块钱。你买瓶水喝够了。
网上不管什么代码都有卖的,三五块钱一大把,python我也买过,只是JavaScript我根本不懂,看不明白,想学又总感觉时间没那么充分就一直拖着。我要是也会JavaScript我就自己弄一个小程序,还省的花钱。
页:
[1]