Rezultati

Up. imeNalogaJezikRezultatČas oddaje
delta-2017 Hodnik Python 3 100/100OK 20. apr '17 @ 18:13

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

Ocenjevani program (hodnik.py):
string=input()
n=len(string)
niz="01"*(n//2)+"0"*(n%2)

prva=0
druga=0

for i in range(n):
    if string[i]==niz[i]:
        prva+=1
    else:
        druga+=1

print(min(prva, druga))



"""def spremeni(string, mesto):
    if string[mesto]=='1':
        return string[:mesto] + '0' + string[mesto+1:]
    else:
        return string[:mesto] + '1' + string[mesto+1:]


def preveri(string):
    for i in range(1, len(string)):
        if string[i-1] == string[i]:
            return False
    return True

spremembe = 0
mesto = 0
def main2(string, mesto, spremembe):
    if mesto >= len(string):
        return 1001
    string2 = spremeni(string, mesto)
    if preveri(string):
        return spremembe
    elif preveri(string2):
        return spremembe+1
    else:
        return min(main2(string,mesto+1,spremembe),main2(string2,mesto+1,spremembe+1))

"00100110101"
print(main2(string,0,0))"""