Grooving Monkey Program In Python

 def grov_monkey(r):

    z=r

    x=[0]*len(r)

    c = 0

    while(x!=r):

        c+=1

        x=[0]*len(r)

        for i in range(len(r)):

            x[r[i]-1]=z[i]

        z=x

    return (c)

t=int(input())

for i in range(t):

   m,n=list(map(int,input().split())),int(input())

    res=grov_monkey(m)

    print(res)

Comments

Popular posts from this blog

Swayamvar Program In Python

VALDATION IN JAVASCRIPT