Hello All!

Question : 
https://codingcompetitions.withgoogle.com/codejam/round/00000000000516b9/0000000000134c90
Was just trying out the robot programming strategy problem for practice. 
But I feel I am missing some constraint which is giving me an wrong  
answer. Here's my solution in Python3.

T = int(input())
t = 1
cas = ["P","R","S"]
while(t <= T):
    res = ""
    A = int(input())
    l = []
    for i in range(A):
        l.append(input())
    pos = 0
    while(len(l) > 0):
#        print(l)
        al = []
        for i in l:
            if(i[pos%len(i)] not in al):
                al.append(i[pos%len(i)])
        if(len(al) == 1):
            res += cas[(cas.index(al[0])-1)%3]
            l.clear()
        elif(len(al) == 3):
            res = "IMPOSSIBLE"
            l.clear()
        else:
            al = sorted(al)
            if(al[1] == "S" and al[0] == "P"):
                res += "S"
            else:
                res += al[0]
            l = list(filter(lambda x: x[pos%len(x)] != al[1],l))
            pos += 1
    print("Case #{}: {}".format(t, res))
#    print("Case #",t,": ",res,sep="")
    t += 1

Would be great, if someone could point out where I am going Wrong.

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/b4f68665-8c3a-4cac-b0f5-59d662b70dbc%40googlegroups.com.

Reply via email to