Rezultati

Up. imeNalogaJezikRezultatČas oddaje
vlakectomaz-2017 Jungle Speed Python 3 100/100OK 11. maj '17 @ 18:19

Test Točke Porabljen spomin Porabljen čas Status
#1 9/9 8,605 MiB 0,000 s OK
#2 9/9 8,617 MiB 0,000 s OK
#3 9/9 8,598 MiB 0,000 s OK
#4 9/9 8,625 MiB 0,000 s OK
#5 9/9 8,609 MiB 0,000 s OK
#6 9/9 8,602 MiB 0,000 s OK
#7 9/9 8,625 MiB 0,000 s OK
#8 9/9 8,633 MiB 0,000 s OK
#9 9/9 8,617 MiB 0,000 s OK
#10 9/9 8,625 MiB 0,000 s OK
#11 10/10 8,633 MiB 0,000 s OK

Ocenjevani program (jungle.py):
N=int(input())
karte=[int(x) for x in input().split(" ")]
kupcki=[[] for x in range(N)]
naMizi=[[] for x in range(N)]

for i in range(len(karte)):
	kupcki[i%N].append(karte[i])

#print(kupcki)

def stKart():
	kupckiS = (len(x) for x in kupcki)
	mizaS = (len(x) for x in naMizi)
	return (m+k for k,m in zip(kupckiS,mizaS))

i=0
while(min(stKart())>0):
	if(len(kupcki[i])==0):
		kupcki[i]=naMizi[i][::-1]
		naMizi[i]=[]

	k=kupcki[i].pop()
	naMizi[i].append(k)
	
	par = [x[-1]==k if len(x) > 0 else False for x in naMizi]
	par[i] = False
	if(True in par):
		parI = par.index(True)
		kupcki[i] = (naMizi[parI] + naMizi[i])[::-1] + kupcki[i]
		naMizi[parI]=[]
		naMizi[i]=[]
		#print("pobral")
	else:
		i=(i+1)%N

	#print("Kupcki: ",kupcki)
	#print("Na mizi: ",naMizi)
	#input()

#print(kupcki)
print(list(stKart()).index(0)+1)