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
from typing import cast

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) -> object:
        return sum_of_ints(cast(list[int], inputs.get("ints")))
    run.run_weekly_challenge(
        run_solution,
        input_example = '{"ints":[1,2,3]}',
        input_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.0.tar.gz (2.9 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.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: run_weeklychallenge-1.0.0.tar.gz
  • Upload date:
  • Size: 2.9 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.0.tar.gz
Algorithm Hash digest
SHA256 339ee0c2dfa8587f185e5a733ce810a47ce1d15a2c18114f8dae7fa840916b1a
MD5 f66ff6b5843293314b2430710a8fc861
BLAKE2b-256 b7384ee88774d34f81c30f52c1423cddb643ac66eb71734ddcfef764ccc8c8ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for run_weeklychallenge-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7fb6e84a99aa70c92044a696fed90f68b7372bfb2ebcc439dc4dbdd6541b9f2
MD5 026afb50f13ae3bddeb257da81f78b25
BLAKE2b-256 186dc5ae17207c597dd42abc9ed113b82d233a8987a507e4b9787d6b4e4fbb4a

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