Today I tried to solve one of the problems of CODECHEF LONG and I found a solution for it also but when I submitted it, I got WA.
So I wrote a BRUTE FORCE SOLUTION for it and for some testcases which I checked both solution gave same answer so far and I am sure that brute force solution is correct and Now I want to check testcases for which my optimized solution is failing…
So does anyone know how to STRESS TEST a solution using RANDOM TESTCASES GENERATOR…
PLEASE help me if anyone know how to do so…


I usually do something like e.g. this, then run (in bash):

while true; do ./a.out --test | tee last-testcase.txt | ./a.out ; if [ "$?" -ne "0" ]; then break; fi; done

until it either finds a breaking testcase (which will be stored in tee last-testcase.txt) or I get bored :slight_smile:


Sorry but I am unable to understand what you said, see I just used fastolymiccoding STRESS TESTING feature and then it runs many testcases but it’s just showing what is answer given by BRUTE FORCE solution and what answer is given by optimized solution.
It is not showing on which testcase my program gives wrong solution…
I can’t even understand what you wrote… I am new to programming, could you please tell me in an easier way…

1 Like

This is the bash script that I use.

for((i = 1;; ++i)); do
    echo $i
    ./gen $i > in
    diff -w <(./a < in) <(./brute < in) || break

Testing Folder


a.cpp → Wrong Solution
gen.cpp → Test-case generator
brute.cpp → Slow but correct solution → bash script attached above
in → Stores the test-case for which a.cpp fails
Just run the bash script by executing bash command from the testing directory and view the test-case fromin file once the bash script finds a counter-case

1 Like

Thank you for helping me… I found the corner testcase

1 Like

Thank you…I found the corner case…

I have created the same directory structure as you shown in photo but it still giving error no such a file or directory .
can u give me ur discord id so that i can contact with you

request sended (my id : revenge#1213

Either write a code using random library to produce file with inputs
or use
the link

1 Like