Rezultati

Up. imeNalogaJezikRezultatČas oddaje
u3pm Hodnik Python 100/100OK 20. apr '17 @ 18:28

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 6,277 MiB 0,000 s OK
#2 10/10 6,281 MiB 0,000 s OK
#3 10/10 6,250 MiB 0,000 s OK
#4 10/10 6,281 MiB 0,000 s OK
#5 10/10 6,281 MiB 0,000 s OK
#6 10/10 6,410 MiB 0,000 s OK
#7 10/10 6,410 MiB 0,000 s OK
#8 10/10 6,375 MiB 0,000 s OK
#9 10/10 6,410 MiB 0,000 s OK
#10 10/10 6,406 MiB 0,000 s OK

Ocenjevani program (hodnik.py):
import sys

line = sys.stdin.readlines()[0].strip()
#f = open("hodnik.txt")
#line = f.readlines()[0].strip()

n = len(line)
b1 = '1'
b2 = '0'
for i in range(n-1):
    if b1[-1] == '0':
        b1 += '1'
    else:
        b1 += '0'
    if b2[-1] == '0':
        b2 += '1'
    else:
        b2 += '0'



r1 = bin(int(line, 2) ^ int(b1, 2))
r2 = bin(int(line, 2) ^ int(b2, 2))

#print(line, b1, b2, r1[2:], r2[2:])

i1 = 0
i2 = 0
for i in r1[2:]:
    if i == '1':
        i1 += 1
for j in r2[2:]:
    if j =='1':
        i2 += 1

print(min(i1, i2))