1 / 13
Apr 2010

I have been using python 3.0 and have learnt that only. Even my program JULKA was written in python 3.0 and was accepted but as i am going towards some greater programs, i am getting a NZEC error. Can someone please help???

  • created

    Apr '10
  • last reply

    Jul '10
  • 12

    replies

  • 245

    views

  • 6

    users

  • 1

    link

The NZEC's arn't necessarily caused because your program has been developed using Py3. There are lots of other reasons can cause NZECs.
But of course it is definitely recommended to develop your programs compliant to one of the supported releases.

If you getting a run-time error. Then the solution would be like this.
Having made your code a bit more Pythonic (but without altering its flow/algorithm):

def swap(ary, idx1, idx2):
ary[idx1], ary[idx2] = [ary[i] for i in (idx2, idx1)]

def permutations(ordered, movements):
size = len(ordered)
for i in range(1, len(ordered)):
for j in range(movements[i]):
swap(ordered, i-j, i-j-1)
return ordered

numberofcases = input()
for i in range(numberofcases):
sizeofcase = input()
movements = [int(s) for s in raw_input().split()]
ordered = [str(i) for i in range(1, sizeofcase+1)]
ordered = permutations(ordered, movements)
output = " ".join(ordered)
print output

I see it runs correctly in the sample case given at the SPOJ URL you indicate.

Ok, i read somewhere in this forum, that a solution of a problem can here be achieved faster if you give your code. So here I am:
For PALIN: error is NZEC

t=int(input())
for j in range(t):
    a=input()
    b=[]
    for i in a:
        b.append(i)
    for i in range(int(len(b)/2)):
        if b[i]!=b[len(b)-1-i]:
            b[len(b)-1-i]=b[i]
    c=''
    for i in b:
        c+=i
    if c<a:
        if len(b)%2==0:
            b[int(len(b)/2)]=str(int(b[int(len(b)/2)])+1)
            b[int((len(b)/2)-1)]=str(int(b[int((len(b)/2)-1)])+1)
        else:
            b[int(len(b)/2)]=str(int(b[int(len(b)/2)])+1)
        c=''
        for i in b:
            c+=i
    print(c)

For ONP: error NZEC

I believe, now someone would be able to answer me more accurately, why am I getting NZEC's??? These work great on my computer... question question exclamation unamused and imp

My answer was very accurate: http://docs.python.org/py3k/whatsnew/3.0.html5
If you read this, you know why your code gives NZEC. If reading that is too much work for you - okay, just wait for a more accurate answer of someone, who read it ...

Thanks a lot...!!! smile astonished
My programs are working now. All I do is change input() to raw_input and remove the paranthesis of print.

Ok, I have removed the code for ONP, but the PALIN code is already wrong...

2 months later

Python 3.0 is a new version of the language that is incompatible with the 2.x line of releases. This is the first bugfix release of Python 3.0. Python 3.0 is now in bugfix-only mode; no new features are being added. Dozens of bugs that were reported since the release of 3.0 final have been fixed.

Congrats... Python 3.1.2 has been released. It is very similar to the 3.0 version (what I have seen till now smile ) Only some things have been added...

12 days later

That's some real great news.. Hope, other sites also follow the suite.. smiley smile laughing