티스토리 뷰

"""
 *packageName    : 
 * fileName       : 1439_뒤집기_S5
 * author         : ipeac
 * date           : 2022-03-24
 * description    :
 * ===========================================================
 * DATE              AUTHOR             NOTE
 * -----------------------------------------------------------
 * 2022-03-24        ipeac       최초 생성
 """
import sys


def Solution(s):
      print("==========================================")
      print("s : %s " % s)
      temp = 0
      switch = False
      cnt = 0
      for index, num in enumerate(s):
            if index == 0:
                  temp = num
                  print("temp : %s " % temp)
            
            else:
                  if temp != num:
                        if switch:
                              continue
                        cnt += 1
                        switch = True
                  elif temp == num and switch:
                        switch = False
      print(cnt)


n = list(input())
Solution(n)
# Solution([0, 0, 0, 1, 1, 0, 0])
# Solution([1, 1, 1, 1, 1])
# Solution([0, 0, 0, 0, 0, 0, 0, 1])
# Solution([1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1])
# Solution([1, 1, 1, 0, 1, 1, 0, 1])
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/07   »
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
글 보관함