diff --git a/src/Year_2015/P11.py b/src/Year_2015/P11.py index 4d93578..949fa48 100644 --- a/src/Year_2015/P11.py +++ b/src/Year_2015/P11.py @@ -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)