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:

import run_weeklychallenge as run
import run

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

def main() -> None:
    def run_solution(inputs: object) -> str:
        return str(sum_of_ints(cast(list[int], cast(dict, inputs).get("ints"))))
    run.run_weekly_challenge(
        run_solution,
        inputs_example = '{"ints":[1,2,3]}',
        inputs_schema_json = '''{
            "type": "object",
            "properties": {
                "ints": {
                    "type": "array",
                    "items": { "type": "integer" }
                }
            },
            "required": ["ints"],
            "additionalProperties": false
        }'''
    )

if __name__ == '__main__':
    main()

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.

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.1.tar.gz (3.2 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.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: run_weeklychallenge-1.0.1.tar.gz
  • Upload date:
  • Size: 3.2 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.1.tar.gz
Algorithm Hash digest
SHA256 50429398d438cf706029db6fe6458b0e72e3f36dfdeec849e6365db1b2fb87c5
MD5 efa3de841428249c72c20022396d663c
BLAKE2b-256 059ae0f688155751d42ac30d8e1453dbd3e2bc5ec1c37e9f9b2b6471352ee084

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for run_weeklychallenge-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e441403571c19a45f0f698c4a5656e399b38564c9023d746fae69f82d5d46cb7
MD5 7c42c9f0c0d0d7bd157dcf89188da66e
BLAKE2b-256 2c07f300c5ade87671dbf3eb436ca5b0d1d9e25978ef75ef68d99b6393423e94

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