3

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))
3
  • why do you post the same question twice? Commented Jun 29, 2013 at 5:27
  • well... I am never able to find out the correct reason for a run time error...the earlier one was for a different code... and this is a different code. Commented Jun 29, 2013 at 5:52
  • Hope my answer helps you Commented Jun 29, 2013 at 5:53

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

2

Many times it is due to some white places left.

Try this:

raw_input().strip().split(" ") 

if the data is separated by " ".

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.