Getting NZEC error in Python 3.5

here is the question - https://www.codechef.com/problems/RAINBOWA

here is the solution - https://www.codechef.com/viewsolution/15074505

I cannot get around as to why I am getting an NZEC error. The code runs on boundary conditions too but still.

Test case:

1
14
1 2 3 4 5 6 7 7 6 5 4 3 2 1

This gives runtime error, see:

Traceback (most recent call last):
  File "rainbow.py", line 22, in <module>
    check(z)
  File "rainbow.py", line 12, in check
    m=b.index(j)
ValueError: 0 is not in list
1 Like

Hey @shashere_92,

Your code is working fine on the local compiler and also on codechef ide. Instead, your approach to solving the problem is not correct because the output for even sample test case is wrong.

please follow the link
How to solve RAINBOWA or this code in python.

Hope this helps!