I had a working code in python and i placed assert(False) in between an arbitrary pair of lines. Still outputs correct answer in codechef interpreter although in my own interpreter it throws AssertionError.
Hi, sorry for the very delayed reply. As you can see from Are any compiler flags set on the online judge? - #2 by admin, the OO flag is used on Codechef, and that ignores asserts, as explained here: optimization - What are the implications of running python with the optimize flag? - Stack Overflow
Here is what I have used while testing for my contest on CodeChef:
def pyassert(v):
if v==False:
a=2/0
And then replaced all ‘assert’ with ‘pyassert’. This gives run time error in all failing conditions.
Alternatively, You can also use,
from numpy.testing import assert_
and then replace all ‘assert’ with ‘assert_’.
2 Likes