#31 백준[1110] 더하기 사이클
https://www.acmicpc.net/problem/1110
#Solution
#먼저 함수를 만들어보자
def howplus(num):
if num < 10:
num_str = str(num)
num_list = list([0,num_str])
num2 = int(num_list[0]) + int(num_list[-1])
num2_str = str(num2)
num2_list = list(num2_str)
num2_final = int(num_list[-1])*10 + int(num2_list[-1])
return num2_final
else:
num_str = str(num)
num_list = list(num_str)
num2 = int(num_list[0]) + int(num_list[-1])
num2_str = str(num2)
num2_list = list(num2_str)
num2_final = int(num_list[-1])*10 + int(num2_list[-1])
return num2_final
#이제 넣어보자
input_num = int(input())
k = howplus(input_num)
#몇 번 돌렸는지 확인하는 함수
a=1
while True:
if input_num != k:
a = a + 1
k = howplus(k)
else:
print(a)
break
'Programming [Python] > 백준 알고리즘 솔루션' 카테고리의 다른 글
#33 백준 파이썬 [1065] 한 수 (0) | 2019.02.23 |
---|---|
#32 백준 파이썬 [4673] 셀프 넘버 (0) | 2019.02.21 |
#30 백준 파이썬 [4344] 평균은 넘겠지 (0) | 2019.02.21 |
#29 백준 파이썬 [1546] 평균 (0) | 2019.02.21 |
#28 백준 파이썬 [10871] X보다 작은 수 (0) | 2019.02.21 |