forked from ndb796/python-for-coding-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.py
More file actions
21 lines (18 loc) · 541 Bytes
/
3.py
File metadata and controls
21 lines (18 loc) · 541 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
data = input()
count0 = 0 # 전부 0으로 바꾸는 경우
count1 = 0 # 전부 1로 바꾸는 경우
# 첫 번째 원소에 대해서 처리
if data[0] == '1':
count0 += 1
else:
count1 += 1
# 두 번째 원소부터 모든 원소를 확인하며
for i in range(len(data) - 1):
if data[i] != data[i + 1]:
# 다음 수에서 1로 바뀌는 경우
if data[i + 1] == '1':
count0 += 1
# 다음 수에서 0으로 바뀌는 경우
else:
count1 += 1
print(min(count0, count1))