From a8e55eeff4664399534426949f345440394f63ed Mon Sep 17 00:00:00 2001 From: daviddoji Date: Mon, 13 Jun 2022 21:15:01 +0200 Subject: [PATCH] Solution to problem 11 in Python --- src/Year_2015/P11.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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)