처음 풀었을때.. 제출하고 보니 뭔가 더 효율적으로 풀 수 있을 것 같다.
no_self_num = list()
division = [1000, 100, 10, 1]
for n in range(1, 10000 + 1):
result = n
for d in division:
result += n // d
n = n % d
if result > 10000:
continue
no_self_num.append(result)
for n in range(1, 10000 + 1):
if n not in no_self_num:
print(n)
no_self_num = set() # 중복 없이 저장 가능
def d(n):
n =n + sum(map(int, str(n))) # sum(map(int, str(n))) 각 자리의 숫자들의 합을 구할 수 있다.
return n
for n in range(1, 10000 + 1):
no_self_num.add(d(n))
for n in range(1, 10000 + 1):
if n not in no_self_num:
print(n)