
Crontab Parsing

Linux Crontab command is a powerful utility that is used for scheduling and automating tasks in Unix-like operating systems.
In this mission your task is to parse a crontab timing expression (crontab format MIN HOUR DOM MON DOW
), return a sorted ascending list of next 3 execution datetimes based on a provided current datetime (ISO format YYYY-MM-DDTHH:MM
).
Your script must support all standard crontab expressions:
- Single numbers: 5, 10, 15;
- Ranges: 1-5;
- Steps: */2, 1-10/2;
- Lists: 1,3,5;
- Special character: *;
- Special keywords: @yearly (@annually), @monthly, @weekly, @daily (@midnight), @hourly.
Input: Two strings (str).
Output: List of three strings (str).
Examples:
assert next_crontab_exec("* * * * *", "2025-03-03T14:30") == [ "2025-03-03T14:31", "2025-03-03T14:32", "2025-03-03T14:33", ] assert next_crontab_exec("*/15 * * * *", "2025-03-03T14:30") == [ "2025-03-03T14:45", "2025-03-03T15:00", "2025-03-03T15:15", ] assert next_crontab_exec("5,10,15,20 * * * *", "2025-03-03T14:07") == [ "2025-03-03T14:10", "2025-03-03T14:15", "2025-03-03T14:20", ] assert next_crontab_exec("10-20 * * * *", "2025-03-03T14:05") == [ "2025-03-03T14:10", "2025-03-03T14:11", "2025-03-03T14:12", ]