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.3.tar.gz (3.4 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.3-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: run_weeklychallenge-1.0.3.tar.gz
  • Upload date:
  • Size: 3.4 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.3.tar.gz
Algorithm Hash digest
SHA256 363ce3e18bc5283c452f3c1554f95a58e342aefad806df05f34486eb10b75da8
MD5 45e08550a0683c96277cbde87e400701
BLAKE2b-256 6ea607a6b488538fcee3a6f9df386fa8079ddf5904601f614a0b61c8be09621f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for run_weeklychallenge-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2981026a29e7556ccb8015bd40c3ef78bc9862c5214639abc37435dcb4df361c
MD5 a0b15acaab90515bcef408ad6077ac19
BLAKE2b-256 600e4d1a71ba8479af8cb002ab392f77ac000a61a7da8bd698ec417f1321873f

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