기억은 짧고 기록은 길다
[프로그래머스/Programmers] 이진 변환 반복하기 - Python 본문
Link
코딩테스트 연습 - 이진 변환 반복하기
programmers.co.kr
Solution
def solution(s):
answer = [0, 0]
while s != '1':
count_0 = s.count('0')
count_1 = s.count('1')
answer[0] += 1
answer[1] += count_0
s = bin(count_1)[2:]
return answer
🔑 key point: count(), bin()
📌 Tip: bin()[2:]'CodingTest > programmers' 카테고리의 다른 글
| [프로그래머스/Programmers] 짝지어 제거하기 - Python (0) | 2021.09.21 |
|---|---|
| [프로그래머스/Programmers] 주식가격 - Python (0) | 2021.09.21 |
| [프로그래머스/Programmers] 전화번호 목록 - Python (0) | 2021.09.21 |
| [프로그래머스/Programmers] 위장 - Python (0) | 2021.09.19 |
| [프로그래머스/Programmers] 예상 대진표 - Python (0) | 2021.09.17 |
Comments