Skip to content

Commit f12ddc7

Browse files
authored
[BOJ] 1439 뒤집기 (S5)
1 parent 1cce6d6 commit f12ddc7

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

김지호/7주차/260210.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# https://www.acmicpc.net/problem/1439
2+
# 뒤집기, 실버5
3+
4+
import sys
5+
sys.stdin = open("../../../input.txt",'r')
6+
7+
S = input()
8+
9+
one_count = 0
10+
zero_count = 0
11+
12+
index = 0
13+
length = len(S)
14+
15+
while index < length:
16+
17+
# index 위치부터 연속된 지역까지 탐색하기
18+
curr_index = index
19+
number = S[index] # 초기 숫자
20+
21+
while curr_index < length and number == S[curr_index]:
22+
curr_index += 1
23+
24+
if number == '0':
25+
zero_count += 1
26+
else:
27+
one_count += 1
28+
29+
index = curr_index
30+
31+
# print(f"zero_count : {zero_count}")
32+
# print(f"one_count : {one_count}")
33+
print(min(zero_count,one_count))

0 commit comments

Comments
 (0)