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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f366bee60c12b48a697ff71c6d419dd44b3414552169228673272324721bf36b
|
|
| MD5 |
1e149838bbc1fdb0ea68d3fbe48687fb
|
|
| BLAKE2b-256 |
29ef18d932fb6fe4e721c4d0984035436160b91fe6fd32617f64221b9b48c8b4
|
File details
Details for the file run_weeklychallenge-1.0.6-py3-none-any.whl.
File metadata
- Download URL: run_weeklychallenge-1.0.6-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c82e43495ca92221e8817de989eddd681d1725aab2a56024cfb8cb82f59fdc63
|
|
| MD5 |
5214a4b8e0b1e7cf867884396340f2d1
|
|
| BLAKE2b-256 |
935f354acd2a4ed3d317daa0ee7f2c594426c362eaf06313b51380e3580733fd
|