Download data/software-parse_duration-2/solution.py from stoiclion/agent-workbench: direct link, hf CLI and curl.
- Browser
- Download file 268 Bytes
-
https://huggingface.co/datasets/stoiclion/agent-workbench/resolve/main/data/software-parse_duration-2/solution.py
- Command line
-
hf download hf://datasets/stoiclion/agent-workbench/data/software-parse_duration-2/solution.py
-
curl -L -o solution.py https://huggingface.co/datasets/stoiclion/agent-workbench/resolve/main/data/software-parse_duration-2/solution.py
268 Bytes
| def parse_duration(text): | |
| """Parse durations like '1h30m', '45s', '2h5s' or '90m' into total seconds.""" | |
| import re | |
| total = 0 | |
| for value, unit in re.findall(r"(\d+)([hm])", text): | |
| total += int(value) * {"h": 3600, "m": 60}[unit] | |
| return total | |