코딩 테스트 (Coding Test)

[프로그래머스] 이진 변환 반복하기

Universe_lee 2023. 1. 16. 16:42

나의 풀이

def solution(s):
    answer = [0, 0]
    
    while True:
        if s == '1':
            break
           
        cur = s.count('0')
        s = bin(len(s) - cur)[2:]
        answer[0] += 1
        answer[1] += cur

    return answer