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.6.tar.gz (3.5 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.6-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for run_weeklychallenge-1.0.6.tar.gz
Algorithm Hash digest
SHA256 f366bee60c12b48a697ff71c6d419dd44b3414552169228673272324721bf36b
MD5 1e149838bbc1fdb0ea68d3fbe48687fb
BLAKE2b-256 29ef18d932fb6fe4e721c4d0984035436160b91fe6fd32617f64221b9b48c8b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for run_weeklychallenge-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 c82e43495ca92221e8817de989eddd681d1725aab2a56024cfb8cb82f59fdc63
MD5 5214a4b8e0b1e7cf867884396340f2d1
BLAKE2b-256 935f354acd2a4ed3d317daa0ee7f2c594426c362eaf06313b51380e3580733fd

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