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.4.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.4-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: run_weeklychallenge-1.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 6935fc5fd24b9f9c1348308ccd4df963ea2c3b951d68172516fcd90efee88b04
MD5 a8b3723707f8797a154dd76ec5711500
BLAKE2b-256 4e0055eba1a0f4478b80c7b15e141c10f5086e504a58bfa6a2a185474cedc08f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for run_weeklychallenge-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 52e5229fde883efabff6f984a6bb6e4fbdaf412cfad692396ca14822b050353e
MD5 1db2528f6402c4de32c391e44e33ede1
BLAKE2b-256 bf353e20624a1f42e1bb638ad6d93a8d44642658bdd8eee97644bd4a650d69c1

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