Reputation: 47
It works fin in my pc and in an online compiler+debugger. However, when I submit it in codechef, it gives me a runtime error(nzec). When do you get a runtime error and how to you resolve it. What is the problem in this code? I keep getting runtime error very frequently. How do I avoid it? Any kind of help will be deeply appreciated!
t = int(raw_input())
for i in range(t):
a = map(int, raw_input())
if a.index(min(a)) != 0:
if min(a) == 0:
print a.index(min(a))
else:
print str(str(a.index(min(a))) * (min(a)+1))
elif a.index(min(a)) == 0:
k = min(a)
a[0] = 99
l = min(a)
if l == k:
print str(str(a.index(min(a))) * min(a))
elif l > k:
print '1'+ ('0' * (k+1))
Upvotes: 3
Views: 2660
Reputation: 138
Many times it is due to some white places left.
Try this:
raw_input().strip().split(" ")
if the data is separated by " ".
Upvotes: 2
Reputation: 11070
You have to split the raw_input()
raw_input()
receives the input as just a string. Use raw_input().split()
to convert the string to a list. Else you will have indexing problems, since the spaces given in the input are taken for mapping. So you get the nzec (non-zero exit code) error
a=map(int,raw_input().split())
will do
Upvotes: 2