| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 
| 9 | 10 | 11 | 12 | 13 | 14 | 15 | 
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | 
| 23 | 24 | 25 | 26 | 27 | 28 | 29 | 
| 30 | 
                                        Tags
                                        
                                    
                                        
                                    - markdown
 - 파이썬머신러닝완벽가이드
 - 피보나치 수
 - All Longest Strings
 - data_structure
 - 10953
 - adjacentElementsProduct
 - til
 - C++
 - 2015 봄학기 알고리즘
 - almostIncreasingSequence
 - 백준
 - shapeArea
 - matrixElementsSum
 - collections.deque
 - baekjun
 - centuryFromYear
 - 수 정렬하기
 - 파이썬 포렌식
 - Sequential Search
 - 2750
 - codesingal
 - Counting cells in a blob
 - cpp
 - Python
 - Daily Commit
 - codesignal
 - recursion
 - flask
 - Numpy
 
                                        Archives
                                        
                                    
                                        
                                    - Today
 
- Total
 
Introfor
Persistent Bugger 본문
from functools import reduce
이 모듈은 처음 써보는데 편리하게 사용할 수 있을 것 같다.
| 
 1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
 | 
 from sys import stdin 
from functools import reduce 
n = int(stdin.readline()) 
cnt = 0 
while n >= 10: 
    n_list = list(str(n)) 
    n = reduce(lambda x, y: int(x)*int(y), n_list) 
    cnt += 1 
print(cnt) 
 | 
cs | 
다른 소스코드
| 
 1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
 | 
 def persistence(n): 
    n = str(n) 
    count = 0 
    while len(n) > 1: 
        p = 1 
        for i in n: 
            p *= int(i) 
        n = str(p) 
        count += 1 
    return count 
 | 
cs | 
이렇게 모듈을 사용하지 않는 방향으로 학습하는게 좋다. 내가 원하는 모듈도 만들어 보는 것도 좋겠다.
'Programming_prob > Codewares' 카테고리의 다른 글
| Complementary DNA (0) | 2020.09.20 | 
|---|---|
| Descending Order (0) | 2020.09.20 | 
| Who likes it (0) | 2020.09.20 | 
                          Comments