fork download
  1. g=lambda x:0**x or x*g(x-1)
  2. f=lambda a,i,n=0,l=[]:(i<0)+(i>=len(a))and n or(0 if i in l else f(a,[a[i],i-a[i]][i and-g(i-1)%i],n+1,l+[i]))
  3.  
  4. print(f([2,5,6,8,1,2,3], 3))
  5. print(f([2, 0, 2], 2))
  6. print(f([14,1,2,5,1,3,51,5,12,3,4,41,15,4,12,243,51,2,14,51,12,11], 5))
Success #stdin #stdout 0.03s 9984KB
stdin
Standard input is empty
stdout
1
0
6