Datasets:
Download code/math_code_012_solution.py from efe-T/bilingual-math-code-verification-v1: direct link, hf CLI and curl.
- Browser
- Download file 678 Bytes
-
https://huggingface.co/datasets/efe-T/bilingual-math-code-verification-v1/resolve/main/code/math_code_012_solution.py
- Command line
-
hf download hf://datasets/efe-T/bilingual-math-code-verification-v1/code/math_code_012_solution.py
-
curl -L -o math_code_012_solution.py https://huggingface.co/datasets/efe-T/bilingual-math-code-verification-v1/resolve/main/code/math_code_012_solution.py
678 Bytes
| from fractions import Fraction as F | |
| segments = [(F(15), F(25), F(1, 5), F(0)), | |
| (F(25), F(35), F(0), F(5)), | |
| (F(35), None, F(1, 5), F(-2))] | |
| b_speed, b_offset = F(3, 10), F(-9, 2) | |
| meetings = [] | |
| for lo, hi, a_speed, a_offset in segments: | |
| t = (b_offset - a_offset) / (a_speed - b_speed) | |
| if t >= lo and (hi is None or t <= hi): | |
| meetings.append(t) | |
| t = min(meetings) | |
| seconds = t * 60 | |
| assert seconds.denominator == 1 | |
| position = b_speed * t + b_offset | |
| result = {"seconds_after_A": int(seconds), "seconds_after_B": int(seconds - 900), | |
| "distance_km": str(position)} | |
| import json | |
| print(json.dumps(result, ensure_ascii=False, sort_keys=True)) | |