Hello guys
I'm here to share a new software I made (open source) for competitive programming. After being a bit frustrated with the vanilla sdiff
and diff
I decided to create my own stuff, since I didn't find anything simple like I wanted.
https://github.com/ChrisVilches/cpdiff
Usage is also quite easy, like (there are more ways of using it, as stated in the readme):
./your_program < data.in | cpdiff data.out
Basically the idea is to have a more ad-hoc diff tool for competitive programming. Also it has green text when all answers are correct, and who doesn't like seeing more green on screen? lol
It can be installed via NPM as the readme says.
Some features:
- Ignores extra spaces and lines (kind of opinionated, but the main priority in my program is to debug calculations rather than focusing on avoiding presentation errors)
- When a numeric line is detected, it does a comparison using a certain error (currently $$$10^{-5}$$$ is hardcoded. Configuration may come in the future). Therefore you can still get the "Accepted" text but with a warning that some numbers might be inaccurate. If the line contains many numbers, they are all compared to their counterparts in the compared file.
- When a line is detected to be non-numeric, a raw vanilla string comparison is done.
There are still several things that I'd like to add, but it's kind of beta right now. I might continue to add features if I have more users. Contributions are also welcome.
Lovely tool!! But can you please explain how you detected a non-numeric line? Certain CF outputs only consist of digits but they are mainly strings — like 10100011111111111111101101010101010101010101000000. How did you deal with them? Just asking out of curiosity.
The current way is by doing a check using a Regex that basically matches strings such as
123 456
(two numbers in one line),-23.45
(negative),34 34.03434 454.11 -123.33
, etc. And if it doesn't match, then it's handled as a raw string.In your example (
10100011111111111111101101010101010101010101000000
) it'd be handled as a numeric string, and I just checked and the comparison doesn't work due to the number being too long haha.Thanks for the implicit bug report, I'll fix it ;)
A quick fix would be to add a character limit to the regex, which is what I'd like to implement (not sure yet).
looking forward to it!