Rezultati

Up. imeNalogaJezikRezultatČas oddaje
fmffml-2017 Hodnik Python 3 100/100OK 20. apr '17 @ 16:56

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 8,637 MiB 0,000 s OK
#2 10/10 8,633 MiB 0,000 s OK
#3 10/10 8,621 MiB 0,000 s OK
#4 10/10 8,605 MiB 0,000 s OK
#5 10/10 8,629 MiB 0,000 s OK
#6 10/10 8,629 MiB 0,000 s OK
#7 10/10 8,605 MiB 0,000 s OK
#8 10/10 8,621 MiB 0,000 s OK
#9 10/10 8,637 MiB 0,000 s OK
#10 10/10 8,633 MiB 0,000 s OK

Ocenjevani program (hodnik.py):
def hodnik(data):
    n = len(data)
    prva = [1 if i%2==0 else 0 for i in range(n)]
    druga = [0 if i % 2 == 0 else 1 for i in range(n)]
    st1, st2 = 0, 0
    for i in range(n):
        st1 += abs(int(data[i]) - prva[i])
        st2 += abs(int(data[i]) - druga[i])
    return min(st1, st2)


s = input()
print(hodnik(s))