Fixed repeating characters checking

This commit is contained in:
Daniel
2023-01-07 01:28:54 +02:00
committed by GitHub
parent c71c4c8a9f
commit 8caf5696f5

View File

@@ -8,12 +8,18 @@ def checkLength(passw):
def checkRepeating(passw): def checkRepeating(passw):
steps = 0 steps = 0
letters = {x: 0 for x in passw} i = 0
for x in passw: tempSteps = 1
letters[x] += 1 while (len(passw) > 1):
for x in letters: x = passw[0]
if letters[x] > 2: if passw[1] == x:
steps += letters[x] - 2 tempSteps += 1
passw = passw[1:]
else:
if tempSteps > 2:
steps += tempSteps - 2
tempSteps = 1
passw = passw[1:]
if steps == 0: if steps == 0:
return 0 return 0
return steps return steps