Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 프로그래머스타겟넘버파이썬
- One stage detector
- 타겟넘버bfs
- 코딩테스트연습
- Pruning Tutorial
- Object Detection
- Pytorch pruning
- ECCV
- 프로그래머스네트워크
- SSD 리뷰
- 커피후기
- 프로그래머스게임맵최단거리
- 다음큰숫자
- 프로그래머스파이썬
- Single Shot MultiBox Detector
- 코딩테스트네트워크
- Faster R-CNN
- 프로그래머스너비우선탐색
- 프로그래머스타겟넘버
- deep learning
- 코딩테스트2단계
- 프로그래머스bfs
- ssd
- pytorch
- Paper list
- Code Study
- Two stage Detector
- 프로그래머스타겟넘버정답
- 최솟값 만들기
- 프로그래머스
Archives
- Today
- Total
soyeonland
이진 변환 반복하기 본문
cnt_remove_zero = 0
def get_nextlength(s):
global cnt_remove_zero
cnt = 0
for i in s:
if i=="0":
cnt += 1
next_length = len(s)-cnt
cnt_remove_zero += cnt
return next_length
def change_num(num):
tmp_s = ""
share = num//2
res = num%2
tmp_s += str(res)
while(share!=0):
res = share%2
share = share//2
tmp_s += str(res)
new_s = ""
for i in range(len(tmp_s)):
new_s += tmp_s[len(tmp_s)-1-i]
return new_s
def solution(s):
global cnt_remove_zero
cnt_while = 0
# print()
#print(s)
while(s != "1"):
new_num = get_nextlength(s)
s = change_num(new_num)
cnt_while += 1
answer = [cnt_while, cnt_remove_zero]
return answer
'Study > 코딩테스트 연습' 카테고리의 다른 글
짝지어 제거하기 (시간초과 -> 통과) (0) | 2024.07.07 |
---|---|
피보나치수 (0) | 2024.07.04 |
JadenCase 문자열 만들기 (0) | 2024.06.30 |
최솟값 만들기 (0) | 2024.06.30 |
최댓값과 최솟값 (0) | 2024.06.30 |