프로그래머스/Lv. 2
4. 이진 변환 반복하기 (bin, oct, hex)
Seohyeong Lee
2024. 7. 17. 03:30
유형 : 구현
풀이 시간 : 5분
◈
def solution(s):
disappear = 0
cnt = 0
while True:
if s == "1":
break
beforelen = len(s)
s = s.replace("0", "")
disappear += beforelen - len(s)
s = bin(len(s))[2:]
cnt += 1
return [cnt, disappear]
bin을 이용해 쉽게 풀었다.