Skip to main content

KAIST CS453 2019 Spring Team 7 Project

Project description

Coding Test Input Generator

CoTeGen automatically generates test suite of a typical coding test problem from the bottom. First, an initial test suite can be constructed with minimal cost. Next, search-based input generation with mutation fitness complement the initial test suite. Using mutated reference solution as a simplified form of wrong answers, we aim to kill as many mutants as possible. Hence, mutation coverage is provided as a complementary result.

Adding New Reference Solution

After installing our cotegen package, You can write a new reference solution as a simple python file to generate corresponding test cases.

Please locate your reference solution file in examples/tasks directory to utilize command line execution.

You should define a new class inherits cotegen.Task and with the same with filename.

input_parameters, solve(reference solution), compare, and convert_input_to_string are essential methods to override.

Please refer the example:

import cotegen


class CF1A(cotegen.Task):
    input_parameters = \
            'n': cotegen.types.Integer(1, 10**9),
            'm': cotegen.types.Integer(1, 10**9),
            'a': cotegen.types.Integer(1, 10**9),

    def solve(n: int, m: int, a: int) -> int:
        # 1 <= n, m, a <= 10**9
        return ((n + (a-1)) // a) * ((m + (a-1)) // a)

    def compare(user_answer: int, jury_answer: int) -> bool:
        return user_answer == jury_answer

    def convert_input_to_string(n: int, m: int, a: int):
        return "%d %d %d\n" % (n, m, a)

if __name__ == '__main__':
    import os

Define Input Parameters

Predefine the types of input parameters and the range of each argument as a dictionary format.

Currently, CoTeGen supports following types:


Define constraint

If needed, define the constraints among input parameters as list.

constraints = [
        cotegen.constraints.Leq('M', 'N')

You can utilize these predefined constraints:

cotegen.constraints.Leq (Less than or equal)

or, use custom constraints giving custom function (which receives parameter dictionary and returns true/false) as an argument

cotegen.constraints.CustomConstraint(lambda test: 'd1' not in test or 'd2' not in test or test['d1'] != test['d2'])

Command Line Usage

python -m cotegen run random --filename <filename>

python -m cotegen run mutation --filename <filename> --show-survived <true or false>

python -m cotegen run kill --filename <filename> --save <directory path> --mutation-fitness <true or false>

For example:

python -m cotegen run random --filename CF158A

python -m cotegen run mutation --filename CF158A

python -m cotegen run kill --filename CF158A --save ~/Downloads --mutation-fitness true

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cotegen-1.1.tar.gz (17.9 kB view hashes)

Uploaded source

Built Distribution

cotegen-1.1-py3-none-any.whl (24.6 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page