Skip to main content

tools for Online Judge management

Project description

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()

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

oj_tools-0.0.7.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oj_tools-0.0.7-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file oj_tools-0.0.7.tar.gz.

File metadata

  • Download URL: oj_tools-0.0.7.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for oj_tools-0.0.7.tar.gz
Algorithm Hash digest
SHA256 7314ed89b98f184001389ab1381dabb0ffca08e9a71a18805940378a53190b6c
MD5 a476c78398ec4940f39a4240a8267a5e
BLAKE2b-256 262183d3c8da004bfd534be40ba9892a5fd1f5f9e3dd47e3e85d3f2b48ace70d

See more details on using hashes here.

File details

Details for the file oj_tools-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: oj_tools-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for oj_tools-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c945041755ac1c5f82bf31e3d8d0427d6588d233be1b0009744f76ef70929b8a
MD5 22a3645e502fab76c4009a0b84f28b5d
BLAKE2b-256 ccf35772008162472c97f428ce4c9db4d97c5b4cb015967f3ff4162bd0c98541

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page