from collections import Counter
def solution(s):
loop_count = 0 # 이진 변환 횟수
zero_count = 0 # 제거된 모든 0의 개수
while len(s) > 1:
counter = Counter(s)
one_count = counter['1']
zero_count += counter['0']
loop_count += 1
s = format(one_count,'b')
result=[]
result.append(loop_count)
result.append(zero_count)
return result
s="110010101001"
print(solution(s))
'코딩 테스트 > 문제 풀기' 카테고리의 다른 글
[프로그래머스] 피보나치 수 (0) | 2021.03.22 |
---|---|
[프로그래머스] 방문길이 (0) | 2021.03.15 |
[프로그래머스] 최댓값과 최솟값 (0) | 2021.03.15 |
[프로그래머스] 숫자의 표현 (0) | 2021.03.15 |
[프로그래머스] 게임 맵 최단거리 (0) | 2021.03.15 |
댓글