Datasets:
Download code/math_code_005_verify.py from efe-T/bilingual-math-code-verification-v1: direct link, hf CLI and curl.
- Browser
- Download file 438 Bytes
-
https://huggingface.co/datasets/efe-T/bilingual-math-code-verification-v1/resolve/main/code/math_code_005_verify.py
- Command line
-
hf download hf://datasets/efe-T/bilingual-math-code-verification-v1/code/math_code_005_verify.py
-
curl -L -o math_code_005_verify.py https://huggingface.co/datasets/efe-T/bilingual-math-code-verification-v1/resolve/main/code/math_code_005_verify.py
438 Bytes
| from math import sqrt | |
| def volume(x): | |
| return x * (36 - 2 * x) * (24 - 2 * x) | |
| lo, hi = 0.0, 12.0 | |
| ratio = (sqrt(5) - 1) / 2 | |
| for _ in range(100): | |
| a = hi - ratio * (hi - lo) | |
| b = lo + ratio * (hi - lo) | |
| if volume(a) < volume(b): | |
| lo = a | |
| else: | |
| hi = b | |
| x = (lo + hi) / 2 | |
| result = {"cut_cm": round(x, 6), "volume_cm3": round(volume(x), 6)} | |
| import json | |
| print(json.dumps(result, ensure_ascii=False, sort_keys=True)) | |