Solution to problem 11 in Python

This commit is contained in:
David Doblas Jiménez 2022-06-13 21:15:01 +02:00
parent 4c3960b56e
commit a8e55eeff4

View File

@ -57,15 +57,16 @@ def rule_1(chars: list[str]) -> bool:
def rule_2(chars: list[str], pos: int) -> list[str]:
# not contain the letters i, o, or l
# try with next letter
a = ord(chars[pos]) + 1
# rule # 2
# not contain the letters i, o, or l
if a in forbidden_chars:
a += 1
# wraps around to a
if a > 122:
a = 97
chars[pos] = chr(a)
# change now previous letter also
rule_2(chars, pos - 1)
else:
chars[pos] = chr(a)