Datasets:
Download code/math_code_001_solution.py from efe-T/bilingual-math-code-verification-v1: direct link, hf CLI and curl.
- Browser
- Download file 513 Bytes
-
https://huggingface.co/datasets/efe-T/bilingual-math-code-verification-v1/resolve/main/code/math_code_001_solution.py
- Command line
-
hf download hf://datasets/efe-T/bilingual-math-code-verification-v1/code/math_code_001_solution.py
-
curl -L -o math_code_001_solution.py https://huggingface.co/datasets/efe-T/bilingual-math-code-verification-v1/resolve/main/code/math_code_001_solution.py
513 Bytes
| from fractions import Fraction | |
| total = Fraction(20) | |
| low, high, target = Fraction(1, 10), Fraction(3, 10), Fraction(18, 100) | |
| y = total * (target - low) / (high - low) | |
| x = total - y | |
| salt = low * x + high * y | |
| remaining = total - 2 | |
| assert x >= 0 and y >= 0 and x + y == total | |
| assert salt == total * target | |
| assert remaining - salt == total - salt - 2 | |
| result = {"low_kg": str(x), "high_kg": str(y), "final_salt_fraction": str(salt / remaining)} | |
| import json | |
| print(json.dumps(result, ensure_ascii=False, sort_keys=True)) | |