Datasets:
Download code/math_code_008_solution.py from efe-T/bilingual-math-code-verification-v1: direct link, hf CLI and curl.
- Browser
- Download file 418 Bytes
-
https://huggingface.co/datasets/efe-T/bilingual-math-code-verification-v1/resolve/main/code/math_code_008_solution.py
- Command line
-
hf download hf://datasets/efe-T/bilingual-math-code-verification-v1/code/math_code_008_solution.py
-
curl -L -o math_code_008_solution.py https://huggingface.co/datasets/efe-T/bilingual-math-code-verification-v1/resolve/main/code/math_code_008_solution.py
418 Bytes
| from fractions import Fraction | |
| f0, f1, f2 = map(Fraction, (2, 5, 10)) | |
| c = f0 | |
| a = (f2 - 2 * f1 + f0) / 2 | |
| b = f1 - a - c | |
| def f(n): | |
| return a * n * n + b * n + c | |
| assert [f(n) for n in range(3)] == [f0, f1, f2] | |
| result = {"coefficients": [str(a), str(b), str(c)], "f10": str(f(10)), | |
| "sum_1_to_10": str(sum(f(n) for n in range(1, 11)))} | |
| import json | |
| print(json.dumps(result, ensure_ascii=False, sort_keys=True)) | |