hiho week 164 register

Ended

Participants:394

Verdict:Accepted
Score:100 / 100
Submitted:2017-08-20 19:47:40

Lang:Python2

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
while True:
    try:
        n = int(raw_input())
        res = 0
        for i in range(n):
            s = raw_input()
            if s.count('0') == len(s) or s.count('1') == len(s):
                res = 0
            else:
                length = len(s)
                res = length
                for i in range(length+1):
                    cnt = s[:i].count('1') + s[i:].count('0')
                    if cnt < res:
                        res = cnt
            print res
    except:
        break
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX