14 releases (4 breaking)
0.6.0 | Aug 28, 2024 |
---|---|
0.5.0 | Aug 28, 2024 |
0.4.1 | Aug 7, 2024 |
0.4.0 | Jan 30, 2024 |
0.2.9 | Nov 11, 2023 |
#124 in Programming languages
29 downloads per month
89KB
1.5K
SLoC
cpast - Code Testing and Analysis Tool
We are working on making cpast, more accessible and simple for all. If you have experience with python and/or writing prompts, consider contributing to cpast_llm repo.
Introduction
Have you ever found yourself stuck in the middle of a coding contest, frustrated by a bug or an elusive edge case that just won’t reveal itself? Or maybe you’ve spent countless hours comparing outputs manually, only to find that the real problem was a tricky test case you hadn’t considered. Well, I’ve been there, and I have good news: there’s a solution that can change the way you approach competitive programming forever.
Introducing cpast—the game-changing tool designed specifically for competitive programmers and developers who want to enhance their coding efficiency and solve problems faster. Written in Rust for speed and reliability, cpast simplifies the process of comparing outputs from different code files, regardless of the programming language. This allows you to focus on crafting the best solution to your problem without worrying about the technicalities of cross-language compatibility.
Here’s the best part: with cpast, all you need is your solution file and the input format, and you can debug your code to perfection without having to look at or rely on anyone else’s code. No more peeking at other people's solutions to figure out what went wrong. Now, you can independently find those tricky cases that make all the difference, allowing you to learn and improve your problem-solving skills honestly and effectively.
Checkout the blog post here
Usecases
- Debugging your CP/DSA questions.
- Live hacking in during/post Codeforces contests.
- Generate testcases for problem setters.
- Reinforcement learning for large language models and stress testing their code generation accuracy.
Getting Started
https://github.com/user-attachments/assets/3b7d5b88-5a2a-4d01-8d5b-31f86b9a96db
Installation
To get started with cpast
, you need to install it. You can do this by running the following command:
cargo install cpast
Installing cargo on Windows
On windows, to install cargo, run these commands in terminal (for faster and lighter setup)
winget install rustup
rustup toolchain install stable-x86_64-pc-windows-gnu
rustup default stable-x86_64-pc-windows-gnu
Note for Linux users (clipboard support)
On Linux, you'll need to have xorg-dev and libxcb-composite0-dev to compile. On Debian and Ubuntu you can install them with
sudo apt install xorg-dev libxcb-composite0-dev
Required for clipboard support!
Chances are that clipboard support might be broken for some WMs like bspwm, but other features will work just fine!
In case you get a failing build! (for non supported os)
cpast is pretty minimalistic by default, but to support basic CLI features like clipboard copying etc, we need to depend on system dependencies, whose support may/may not be provided for unsupported OSes!
We have first class support for macOS, Linux (GNOME, KDE, Hyprland) and Windows
Default compilations won't be supported due to lack of clipboard API support in those systems, and hence you need to compile it with --no-default-features
feature
cargo install cpast --no-default-features
Usage
Here's a simple example of how to use cpast
:
test
cpast test -c correct.cpp -t incorrect.cpp -g "(N) (?:N){\1}" --iterations 100
correct.cpp
should contain the correct code.incorrect.cpp
should contain the incorrect code.(N) (?:N){\1}
is the language generator.100
is the number of test iterations.
generate
cpast generate "S[10,@CH_UPPER@]"
- Generates string of length 10, of uppercase characters only
Language Specification
At the heart of cpast is clex, a powerful custom language generator that gives you complete control over input patterns. Imagine regex, but specifically designed for generating random test cases. With clex, you can easily define and automate complex input scenarios to stress-test your code, uncover hidden bugs, and identify edge cases that might otherwise go unnoticed.
For more information on the clex
language and its usage, please refer to the Grammar Rules for Clex Generator.
Meta
Dependencies
~6–19MB
~277K SLoC