One of the way of testing is to generate random test cases that can be solved manually for solutions and test your code against those test cases to figure out the bug…
For Example these are some of the random cases generator for problems of March Long Contest in PYTH 2.7.x
### Test case generator for DEVCLASS
import random
task=[0,1,2]
case=["B","G"]
test=100
print test
for i in range(test):
a=''
print random.choice(task)
siz=random.randrange(1,15)
for j in range(siz):
a+=random.choice(case)
print a
#------------------------------------------------#
#------------------------------------------------#
### Random Test case generator for SINEWAVE
import random
#number of test cases = 50
T=50
def task1():
print T
for i in range(T):
a=""
s=random.randrange(0,12+1)
c=random.randrange(0,12+1)
k=random.randrange(1,25+1)
a+=str(s)+" "+str(c)+" "+str(k)
print a
def task2():
print T
for i in range(T):
a=""
s=random.randrange(0,50+1)
c=0
k=random.randrange(1,50+1)
a+=str(s)+" "+str(c)+" "+str(k)
print a
def task3():
print T
for i in range(T):
a=""
s=random.randrange(0,50+1)
c=random.randrange(0,50+1)
k=1
a+=str(s)+" "+str(c)+" "+str(k)
print a
def task4():
print T
for i in range(T):
a=""
s=random.randrange(0,50+1)
c=random.randrange(0,50+1)
k=random.randrange(1,100+1)
a+=str(s)+" "+str(c)+" "+str(k)
print a
def forTesting():
print T
for i in range(T):
a=""
s=random.randrange(0,10+1)
c=random.randrange(0,10+1)
k=random.randrange(1,10+1)
a+=str(s)+" "+str(c)+" "+str(k)
print a
forTesting()
Copy random test cases in a file named test with extension .in in same directory your source code is saved and test your code or you may use ideone or codechef IDE …
Believe me you need patience but this works for 70-80% of the time…
the biggest problem I’m having is the codechef runs the code, then says ‘wrong answer’, but no feedback as to what was wrong with the output from my program.
My program works for the presented inputs and meets (as I read the criteria) all the listed criteria.
Learn gdb from here and here (vedios from CS50 by harvard).It is a commandline runtime debugging tool. It supports many languges but the tutorials are specifically for c and can be extended to c++ easily. For other languages also you can find the tutorials.
It makes debuggig really faster and you dont have to change your program again and again for debugging,
in manually u can check all the possible inputs into it and can check out. i used this method to test my last work about kerala houseboat packages. also there are a lot of testing tools are available in the market.
}
This is my program for input and output processing but codechef is giving me wrong answer. I even tested this answer on ideone and there it got successfully executed. so why codechef is giving me wrong answer??
We test our code in other sites and ide they work fine there, but when submit in codechef it simply says WRONG ANSWER. seriuosly? shouldn’t it clearly state whats went wrong. Its so irritating ti see that message again and again having no idea what did go wrong.
seriously man,
workin on a code, i submit solution to the problem it accepts subtask1 and showing wa for subtask 2. i have test almost all possible inputs but it simply shows wa all time,
it should give feedback of what went wrong…
This is the most irritating issue i face here.
CodeChef should provide hints or useful feedback when it throws WA. Let them reduce points/stars but provide a meaningful response. Thats the least i expect !
The current UI doesn’t look intuitive & reduces engagement levels of beginners like me
If it tells, whats wrong in your code, what did you learn then? Like this, every other person will get AC, because of the hints. At the end of each round, editorial is published. Do refer to that, if you were not able to solve any problem
In that case lets extend your argument and ask What is the fun in revealing full editorial afterwards but hiding the test case failure reason when the person is actually engrossed?
No / delayed feedback == Delayed learning && Low engagement.
PS: Not everyone is here for the stars / ratings. Most beginners look for smooth learning curve.