Spaces:
Sleeping
Sleeping
Download dataset/problem_18/buggy.py from Viraj0112/rl_code_fix_env: direct link, hf CLI and curl.
- Browser
- Download file 485 Bytes
-
https://huggingface.co/spaces/Viraj0112/rl_code_fix_env/resolve/main/dataset/problem_18/buggy.py
- Command line
-
hf download hf://spaces/Viraj0112/rl_code_fix_env/dataset/problem_18/buggy.py
-
curl -L -o buggy.py https://huggingface.co/spaces/Viraj0112/rl_code_fix_env/resolve/main/dataset/problem_18/buggy.py
485 Bytes
| from dataset.problem_18.math_utils import clamp | |
| def moving_average(nums: list[int], window: int) -> list[float]: | |
| """Simple moving average over a fixed window.""" | |
| if window <= 0: | |
| raise ValueError("window must be positive") | |
| window = clamp(window, 1, len(nums)) | |
| out = [] | |
| # BUG: end index is off-by-one; misses final valid window. | |
| for i in range(0, len(nums) - window): | |
| out.append(sum(nums[i : i + window]) / window) | |
| return out | |