ddfc839Add string-pluck-v1 challenge, solution schema, and scoring toolsJeremy Magland 1"""Loading challenge definitions and submission files."""
2from __future__ import annotations
4import json
5from pathlib import Path
8def load_challenges(challenges_dir: Path) -> dict[str, dict]:
9 out = {}
10 for p in sorted(Path(challenges_dir).glob("*/challenge.json")):
11 with open(p) as f:
12 ch = json.load(f)
13 ch["_dir"] = p.parent
14 out[ch["challenge_id"]] = ch
15 return out
18def load_submissions(solutions_dir: Path) -> list[dict]:
19 """Return every submission JSON under solutions/<challenge-id>/*.json, with _path and _dir_challenge set."""
20 out = []
21 for p in sorted(Path(solutions_dir).glob("*/*.json")):
22 with open(p) as f:
23 sub = json.load(f)
24 sub["_path"] = p
25 sub["_dir_challenge"] = p.parent.name
26 out.append(sub)
27 return out