From 42d15ab5ec07f6d878f32ddfcb83d8dfcf488ac5 Mon Sep 17 00:00:00 2001 From: huisuu Date: Fri, 30 Aug 2024 14:01:17 +0900 Subject: [PATCH] 65.py --- HSKIM/61to70/65.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 HSKIM/61to70/65.py diff --git a/HSKIM/61to70/65.py b/HSKIM/61to70/65.py new file mode 100644 index 0000000..d30d79b --- /dev/null +++ b/HSKIM/61to70/65.py @@ -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))