I have a similar issue. My code runs perfectly on the visible test cases and it
passes. It does not pass for the hidden test cases and gives an RE. I am unable
to figure out the mistake. Any ideas?
My code -
def gcd(a,b):
while(b):
a, b = b, a%b
return a
t = int(input())
for i in range(1,1+t):
n,l = map(int,input().split(" "))
print("Case #{0}: ".format(i),end='')
prod = list(map(int,input().split(" ")))
idx = 0
while prod[idx] == prod[0]:
idx += 1
vals = [gcd(prod[idx],prod[idx+1])]
for x in range(idx,-1,-1):
vals.append(prod[x]/vals[-1])
vals = list(reversed(vals))
for x in range(idx+1,l):
vals.append(prod[x]/vals[-1])
mp = list(sorted(set(vals)))
mp = {k: chr(ord('A')+v) for v, k in enumerate(mp)}
print("{0}".format("".join([mp[x] for x in vals])))
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/110de7df-77e6-4678-93aa-5d54bbf86589%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.