Skip to main content

Facilitates running a solution to https://theweeklychallenge.org using one or more sets of inputs provided as JSON command line arguments.

Project description

Facilitates running a solution to the Weekly Challenge using one or more sets of inputs provided as JSON command line arguments.

Example usage running a "solution" to sum integers:

def sum_of_ints(ints: list[int]) -> int:
    sum: int = 0
    i: int
    for i in ints:
        sum += i
    return sum

if __name__ == '__main__':
    import run_weeklychallenge as run
    run.run_weekly_challenge(
        run_solution = lambda inputs: str(sum_of_ints(run.as_int_list(inputs, 'ints'))),
        inputs_example = '{"ints":[1,2,3]}',
        inputs_schema_json = '''{
            "type": "object",
            "properties": {
                "ints": {
                    "type": "array",
                    "items": { "type": "integer" }
                }
            },
            "required": ["ints"],
            "additionalProperties": false
        }'''
    )

Example output:

$ python example.py '{"ints":[1,2,3]}' '{"ints":[]}'
Inputs: {"ints":[1,2,3]}
Output: 6
Inputs: {"ints":[]}
Output: 0

You must provide an example JSON inputs string (used in error messages), a JSON schema for inputs, and a shim function to run the solution given the decoded JSON inputs and reformat the output if desired. To support type checking, helper functions are provided to extract properties of the JSON input as various types to pass to the solution in the shim function.

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

run_weeklychallenge-1.0.2.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

run_weeklychallenge-1.0.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file run_weeklychallenge-1.0.2.tar.gz.

File metadata

  • Download URL: run_weeklychallenge-1.0.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for run_weeklychallenge-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5b3b0cb5f8cb53df16bef72adf22fcb89dd5bccf032d1c68ce0fb27e5fc7b724
MD5 4d7aee9cd883247e3a71c06898542c53
BLAKE2b-256 5e7c3267ff1bb1b212c1e06dd018ba0705be74500311e556d7a2058abc4fcc64

See more details on using hashes here.

File details

Details for the file run_weeklychallenge-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for run_weeklychallenge-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f9a2343a5d63c647ec3dbbb5c32ca22af6e3b297aca67018afe3b307ea262e71
MD5 ba50ea62a5ceb07ccb5301d7d2803a3b
BLAKE2b-256 bf4d8f62343227fd3a0fc2425d7542d11b96795db185b1f9a9fb3a36c11a281b

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