NumWithCtor = set() # 생성자를 가지고 있는 숫자들

def d(n):
    s = 0 # 각각 자리를 모두 sum하기 위해 0 초기화
    for c in str(n):
        s += int(c)
    return n + s

for n in range(100):
    NumWithCtor.add(d(n))
    if n not in NumWithCtor:
        print(n) 
# reduce 이용버전
from functools import reduce

NumWithCtor = set() # 생성자를 가지고 있는 숫자들

def d(n): 
    return n + reduce(lambda a, x: a+int(x), str(n), 0)

for n in range(100):
    NumWithCtor.add(d(n))
    if n not in NumWithCtor:
        print(n) 
Edit

Pub: 23 Aug 2021 13:31 UTC

Views: 16