Skip to content

Commit

Permalink
65.py
Browse files Browse the repository at this point in the history
  • Loading branch information
huisuu committed Aug 30, 2024
1 parent ba66627 commit 42d15ab
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions HSKIM/61to70/65.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def solution(s):
answer = [0, 0]

while s != '1':
answer[0] += 1 # 이진 변환 횟수 증가
zero_count = s.count('0') # 0의 개수 세기
answer[1] += zero_count # 제거된 0의 개수 누적
s = bin(len(s) - zero_count)[2:] # 0을 제거한 문자열의 길이를 이진수로 변환

return answer

s = "1111111"
print(solution(s))

0 comments on commit 42d15ab

Please sign in to comment.