Skip to main content

oj-tools

QingdaoU/OnlineJudge 를 위한 테스트케이스 생성기입니다.

Install

pip install --upgrade oj-tools

Example

아래는 $N \leq 100$ 인 $N$ 번째 소수를 구하는 문제의 테스트 케이스를 생성하는 예시 입니다.

def prime_generator(hi):
    # Sieve of Eratosthenes
    # https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
    sieve = [True] * (hi+1)
    for p in range(2, hi+1):
        if sieve[p]:
            for j in range(2*p, hi+1, p):
                sieve[j] = False
            yield p


if __name__ == '__main__':
    # 100번째 소수들까지 사전에 구해둡니다.
    # 100번째 소수는 541 입니다. (https://prime-numbers.info/number/100th-prime)
    primes = list(prime_generator(hi=541))

    # 1. Problem 객체를 생성합니다.
    problem = Problem('prime_numbers')

    # 입력 데이터로는 1이상 100 이하의 정수를 일부 사용하며, 테스트케이스 번호는 1부터 세어봅니다.
    for testcase_no, x in enumerate(range(1, 101, 3), start=1):
        # 2-1. input_data에 대한 올바른 output_data를 구합니다.
        y = primes[x-1] # 1-base에서 0-base로 보정

        # 2-2. TestCase 객체를 생성합니다.
        tc = TestCase()

        # 2-3. TestCase 객체에 입출력 데이터를 삽입합니다.
        tc.input.from_args(x)
        tc.output.from_args(y)
        # tc.input.from_file('./sample.txt')
        # tc.input.from_text("""
        #     1 2
        # """, dedent=True)

        # 2-4. 테스트케이스를 문제에 추가합니다.
        problem.add_testcase(tc)

    # 3. 문제의 정보와 테스트케이스를 prime_numbers.zip 파일로 출력합니다.
    problem.extract_as_dir()

Metadata

Release files for oj-tools 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oj-tools 0.0.7
File Size Uploaded
oj_tools-0.0.7.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for oj-tools 0.0.7
File Interpreter ABI Platform
oj_tools-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / oj_tools-0.0.7.tar.gz

Download URL oj_tools-0.0.7.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7314ed89b98f184001389ab1381dabb0ffca08e9a71a18805940378a53190b6c
BLAKE2b-256 checksum
How to use checksums
262183d3c8da004bfd534be40ba9892a5fd1f5f9e3dd47e3e85d3f2b48ace70d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release files / oj_tools-0.0.7-py3-none-any.whl

Download URL oj_tools-0.0.7-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c945041755ac1c5f82bf31e3d8d0427d6588d233be1b0009744f76ef70929b8a
BLAKE2b-256 checksum
How to use checksums
ccf35772008162472c97f428ce4c9db4d97c5b4cb015967f3ff4162bd0c98541
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page