Hello Everyone, I am facing wrong answer in the Saving the Universe again test set 2. I can't find out why. Please help me. My code is written in Python 3
Here is my code: for j in range(int(input())): result = 0 d, inst = input().split() d = int(d) inst = list(inst) num_s = inst.count('S') # Impossible case if num_s > d: print("Case #{}: IMPOSSIBLE".format(j+1)) continue # Possible case dic = [0] i = 0 total = 0 for char in inst: if char == 'S': total += (2**i) dic[i]+=1 else: i+=1 dic.append(0) score = total while d < score: if dic[-1] ==0: dic.pop() result +=1 score -= (2**(len(dic)-2)) dic[-1] -= 1 dic[-2] += 1 print("Case #{}: {}".format(j+1,result)) -- 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 google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/412bcda8-ddda-49e1-8cdd-3be9f7a1e733%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.