I would like to know how CodeChef generates test cases for the problems.[Just curious,so that next time I can generate many test cases and run on my algorithms].
P.S :- Answer appreciated from anyone
I would like to know how CodeChef generates test cases for the problems.[Just curious,so that next time I can generate many test cases and run on my algorithms].
P.S :- Answer appreciated from anyone
You can read this up here.
Also, to generate test cases on your own, you can just follow the input format and constraints and generate test cases using rand(), srand(), random_shuffle() etc functions. You can read about them here. This random test cases generally cover the cases the the solution is slow etc. Corner cases are generally coded by analysis of the problem.
If you feel your question was answered, mark it as accepted.
Happy coding.
For me its skill and experience.
Like, lets say, I ask you to make test cases of a problem where I ask then to tell if a number is prime or not.
First you'd give some random numbers in between the constraints.
Then you'd surely see if they made sure to exclude one from prime numbers.
If you're evil and wanna roast them then you might test against negative inputs too, provided its mentioned in constraints.
You will have to develop it by debugging your program yourself, trying to find the test cases where it fails &etc. Sites like hackerrank and hackerearth may help as they let to access the test case in the end, should you get utterly clueless.
I cant guarantee 100%, but most of the times the problem setters have an idea of what approach people might use to solve their problems and what mistakes they may commit. (Using that, they are able to get the nastiest corner cases to throw up on us during contests :p)
PS: This was more or less for corner cases. For rest of cases @likecs has a better answer.
Hi
We have made a GUI based desktop application to automate generation of random test cases for graph, matrix, arrays and strings.
I have tried to implement all the customization in test cases based on my experience on different platforms.
You can download and use it, if you like
https://sourceforge.net/projects/test-case-generator-toolFor generating a prime, randomised algorithm will fit well, because probabilistically it can be shown that after approximately log(n) steps, we get a prime. You can use miller rabin test to fasten your code for prime checking.
Yes.
Actually I should had clarified, when I talked about the test case generation of prime, I actually meant it at a beginner level, meaning the kind of test cases we make when students are just beginning coding and have n prior experience. Usually those cases have N<=100 or something of that order, so randomised algo was not considered by me.
All in all, my intuition was to show the though process (atleast my thought process) behind making test cases, at basic level.