Untitled

mail@pastecode.io avatar
unknown
python
7 months ago
579 B
3
Indexable
Never
def editor(s):
    result = s

    while ("71" in result) or ("72" in result) or ("73" in result):
        if "71" in result:
            result = result.replace("71", "227", 1)
        if "72" in result:
            result = result.replace("72", "37", 1)
        if "73" in result:
            result = result.replace("73", "17", 1)

    return result

for n in range(1, 1000):
    string = "7" + "1" * (n + 1) + "2" * (n + 2) + "3" * (n + 3)
    result = editor(string)
    result_sum = sum(int(d) for d in string)
    if result_sum == 9 * n:
        print(n)