Flag idle software seats before they renew
Your task
Software subscriptions pile up: seats nobody uses, renewals that fire unnoticed. An agent flags idle seats for each tool's owner, but only when the renewal is close enough to act on.
Write flag_renewal_window_idle_seats(seat_lines, idle_threshold_days, renewal_lead_days): the rule your agent follows for each seat.
seat_lines(list of str): one seat each, writtentool|user|idle_days|kind|days_to_renewal, for example"figma|alice|95|human|40". Akindofservicemarks a service account.idle_daysanddays_to_renewalare whole numbers.idle_threshold_days(int): how long a seat must be idle to count.renewal_lead_days(int): how far ahead of a renewal the agent starts flagging.- Return
"tool:user"for every flagged seat, sorted in ascending order. A row that appears twice is flagged twice.
Rules, for each row:
- Skip a row that does not split on
|into exactly 5 fields. - Skip a service account (kind exactly
service). - Skip a seat idle for fewer than
idle_threshold_days. - Skip a seat whose
days_to_renewalis 0 or less, or aboverenewal_lead_days. - Flag the rest.
Examples
flag_renewal_window_idle_seats(seat_lines: list[str], idle_threshold_days: int, renewal_lead_days: int) -> list[str]Example 1
Input
flag_renewal_window_idle_seats(["figma|alice|95|human|40", "figma|bob|3|human|40", "figma|ci-bot|400|service|40"], 60, 45)Output
["figma:alice"]Example 2
Input
flag_renewal_window_idle_seats(["slack|carol|120|human|120", "slack|dan|120|human|-2", "slack|erin|120|human|30"], 60, 45)Output
["slack:erin"]Example 3
Input
flag_renewal_window_idle_seats(["zoom|zoe|70|human|10", "asana|amy|80|human|10", "zoom|abe|90|human|10"], 60, 45)Output
["asana:amy", "zoom:abe", "zoom:zoe"]