Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 8,387 MiB 0,000 s OK
#2 10/10 8,383 MiB 0,000 s OK
#3 10/10 8,375 MiB 0,000 s OK
#4 10/10 8,387 MiB 0,000 s OK
#5 10/10 8,391 MiB 0,000 s OK
#6 10/10 8,348 MiB 0,000 s OK
#7 10/10 8,344 MiB 0,000 s OK
#8 10/10 8,383 MiB 0,000 s OK
#9 10/10 8,367 MiB 0,000 s OK
#10 10/10 8,387 MiB 0,000 s OK

Ocenjevani program (hallway.py):
import sys

def hallway(s):
    l=list(s)
    l0=[]
    l1=[]
    for i in range(len(l)):
        if i%2==0:
            l0.append('0')
            l1.append('1')
        if i%2==1:
            l0.append('1')
            l1.append('0')
    #print(l0,l1)
    k0=0
    k1=0
    for i in range(len(l)):
        if l[i]==l0[i]:
            k0+=1
        else:
            k1+=1
    return min(len(l)-k0,len(l)-k1)

f=sys.stdin
s=f.readlines()
s=s[0][:len(s)-2]
print(hallway(s))