Programming
[프로그래머스] 이진 변환 반복하기(Python)
데이터현
2021. 11. 3. 22:37
https://programmers.co.kr/learn/courses/30/lessons/70129
코딩테스트 연습 - 이진 변환 반복하기
programmers.co.kr
주어진 조건을 그대로 구현하면 된다.
def solution(s):
deleted_zero, counting = 0,0
while s !='1':
deleted_zero += s.count('0')
counting+=1
s = bin(s.count('1'))[2:]
return [counting,deleted_zero]