Datasets:
Download code/math_code_006_verify.py from efe-T/bilingual-math-code-verification-v1: direct link, hf CLI and curl.
- Browser
- Download file 551 Bytes
-
https://huggingface.co/datasets/efe-T/bilingual-math-code-verification-v1/resolve/main/code/math_code_006_verify.py
- Command line
-
hf download hf://datasets/efe-T/bilingual-math-code-verification-v1/code/math_code_006_verify.py
-
curl -L -o math_code_006_verify.py https://huggingface.co/datasets/efe-T/bilingual-math-code-verification-v1/resolve/main/code/math_code_006_verify.py
551 Bytes
| edges = [("A","B",2),("A","C",3),("B","C",1),("B","D",4), | |
| ("C","D",2),("C","E",3),("D","E",1)] | |
| paths = [] | |
| def visit(path, cost): | |
| if path[-1] == "E": | |
| paths.append((path, cost)) | |
| return | |
| for u, v, weight in edges: | |
| if u == path[-1] and v not in path: | |
| visit(path + [v], cost + weight) | |
| visit(["A"], 0) | |
| best = min(cost for _, cost in paths) | |
| result = {"distance": best, "shortest_path_count": sum(cost == best for _, cost in paths)} | |
| import json | |
| print(json.dumps(result, ensure_ascii=False, sort_keys=True)) | |