Competitive programming testcases made easy!
Project description
Testcase Maker
Competitive programming testcases made easy!
About
**NOTE: The library is a work-in-progress, there may be breaking changes.
When creating competitive programming challenges, we will also need to create testcases. These testcases mey be very large with millions of numbers, which makes it near impossible to do manually. This library will allow you to automatic this process. It provides an intuitive API to build, generate and validate testcases.
Testcase Maker aims to be:
-
Very modular and expandable API structure
-
Fast and efficient
-
Extensive documentation and examples
Testcase Maker is feature-packed with:
-
Highly customisable values to suit large range of challenges
-
Separate constraints for subtasks
-
Execute answer scripts in java, cpp or python to get stdout
Installation
This lib is hosted on pypi, thus you can install this lib by typing the following line below:
pip install testcase-maker
Basics Usage
You can get start generating testcases with just a few lines of code. Here is simple an example of generating testcases with N number of random integers, i.
from testcase_maker.generator import TestcaseGenerator
from testcase_maker.values import ValueGroup, NamedValue, RandomInt, LoopValue, ValueRef
values = ValueGroup()
# Define the N value.
values.add(NamedValue(name="N", value=RandomInt(min=50, max=1000)))
values.newline()
# Define the N number of integers.
values.add(LoopValue(
value=NamedValue(name="i", value=RandomInt(min=1, max=1000)),
amount=ValueRef("N"),
delimiter=" ",
))
# Generate stdin testcases
generator = TestcaseGenerator(values=values)
generator.generate_stdin()
Some challenge has subtasks with testcases requiring different constraints. Continuing from the previous example, here is how you can do it with Testcase Maker.
# ...replacing generator code from the simple example...
# Generate stdin testcases
generator = TestcaseGenerator(values=values)
# Reduce the range of both N and i values.
easy = generator.new_subtask(no_of_testcase=2)
easy.override_value(name="N", value=RandomInt(min=2, max=5))
easy.override_value(name="i", value=RandomInt(min=1, max=100))
# Reduce the range of N. Slightly harder but still less than default.
medium = generator.new_subtask(no_of_testcase=2)
medium.override_value(name="N", value=RandomInt(min=6, max=50))
# Using default constraints. This will generate the largest set of testcases.
hard = generator.new_subtask(no_of_testcase=2)
generator = TestcaseGenerator(values=values)
generator.generate_stdin()
Apart from stdin, you can also generate stdout with an answer script.
# ...replacing generator code from the simple example...
# Generate stdin and stdout testcases
generator = TestcaseGenerator(values=values, answer_script="./solutions.py")
generator.generate()
# solution.py
N = int(input())
numbers = [int(x) for x in input().split()]
numbers.sort()
print(" ".join([str(x) for x in numbers]))
Advanced
There is still so many things you can do with this library. For more advanced and detailed usage guide, please refer to the official documentation!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file testcase-maker-0.2.0.post0.tar.gz
.
File metadata
- Download URL: testcase-maker-0.2.0.post0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91844440e07a7ae28c9e3f35868c7e52d8deddfe8b48e8b59eb002ac36369b8d |
|
MD5 | 28f72d465bd44194158e131ab658778b |
|
BLAKE2b-256 | cf757f54da746f8b4106674e6925e8042ca7a19dc01f4b88b1723b6cdda9d740 |
File details
Details for the file testcase_maker-0.2.0.post0-py3-none-any.whl
.
File metadata
- Download URL: testcase_maker-0.2.0.post0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cebb00a6e55a6dd25dbef31dab22023b15fa670ddbfe44298ca539073fd4f94d |
|
MD5 | 7eb6cda61df896c7c20b18e6128dad9c |
|
BLAKE2b-256 | 2c377b2a1180801f240d56e6cb9a99709b963dc7af4a891c406f2877ec2b9287 |