Bug Finder - A GUI application to compare source codes.

Quite often, as a competitive programmer, I feel irritated when an easy problem yields WA because of a teeny-tiny bug like a typo or a missing initialisation. It often costs a lot of precious time and several penalties.

For this problem, I’ve designed a small, simple, easy-to-use GUI application in Java which takes two source codes and tests them against a common input. The respective outputs obtained are then compared line by line for a mismatch. One can compare the ‘buggy’ code with a brute force solution to obtain a test case in which the faulty solution fails.

Link : https://github.com/sarthakmanna/Bug-Finder
Pre-requisites : Java8 or later must be preinstalled.
Currently supported languages : C++, Java, Python2, Python3

Other details are provided in the ‘README.md’ file of the above git repo.

If you find any bug, please report it at sarthakmannaofficial@gmail.com


Great work bro !!

Really useful app…
Its working nicely…

I have some suggestions for you !!

1) Include TLE

Ask for time limit while taking input and break it if it exceeds time limit. ( if you already have that feature then just ask for time limits. I fear to try it as there is no stop button in your program XD.)
PS: If you can’t do this just give a stop button otherwise it will make hard disk and memory full.(due to infinite loops)

2) Different time limits for both codes would be great.

Usually people have one brute force solution and one optimized one so a feature where I can give different time limits for both test files will be great.

3) Ask for number of times “N” to run on generate test file feature.

Idea is keep generating test cases till either you find a mismatch in answers or it is already executed N times.
Because people will need to run it multiple times with a program which generates inputs using random functions.

Codeforces questions generally don’t have test cases. So it will be easier to use this if you can include this.

Edit:- A stop button is useful for this one as it can be slower. Also showing how many times it is executed is better as we can estimate that how much time it’s gonna take more.

PS: I understand that this can be done with test case but sometimes it’s tough to find that particular test case in generated output/input file (specially when you are in a short contest) and also there can be some programs where including test cases is not feasible due to running contest (specially in short contests) or due to toughness of including test cases in that program or for checking time constraints.

Also Thank you so much for making this bug finder. It’s really a universal bug finder if you can implement above ideas.

I just have a simple bash script for this kind of thing. Essentially I always have a gen.py for test generation and brute.py as a reference solution. Based on that my script does a lot of things. It can generate cases, generate answers for cases and test my solution against the generated cases. Additionally it has convenience features like stress tests (i.e. throw generated cases against solution and brute until the output differs) and performance tests (i.e. throw large generated solutions at the solution and time it).

For me a small hackable script >> gui. :slight_smile:


@algmyr WOW !!! Can you please provide the link to the bash script?

I moved the comment to an answer

Thanks a lot…

I’ve implemented your ideas in my application.

“A stop button is useful for this one as it can be slower. Also showing how many times it is executed is better as we can estimate that how much time it’s gonna take more.” - This stop button is probably the only thing left to add.

Please test the application and report any bug you find.

1 Like

okay sure…

Hi @algmyr, if you could share a sample gen.py and brute.py for any one problem, that will be very helpful.

@ruddradev This answer can’t fit in a comment.

Consider INTEST

gen.py :

import random as rn

n, k = rn.randint(1, 20), rn.randint(1, 50)
print n, k

for i in xrange(n):
	print rn.randint(1, int(500))

brute.py :

count = 0
n, k = map(int, raw_input().split(' '))

for i in xrange(n):
	inp = int(raw_input().strip())
	if inp % k == 0:
		count += 1
print count
  1. Copy and paste the contents of the bash file into a ‘.sh’ file (say bf.sh).
  2. Open terminal and type ‘chmod +x bf.sh’ to make the file executable.
  3. Type ‘./bf.sh’. You should be able to view the available modes.
  4. Generate test cases with ‘./bf.sh generate’.
  5. Generate answers of these cases with ‘./bf.sh answer’.
  6. Finally test your optimised solution with ‘test’ mode.

@algmyr Thank you for sharing such a wonderful bash script.

1 Like

Sorry, I missed this reply. @sarthakmanna had a good example in another answer here.

For the longest time I just re-wrote the same loops for stress testing as one-liners in bash. Then I grew tired of it and put the typical things I used in a script, and then it’s just some minor improvements over time. :slight_smile:

1 Like