Classify a Processing Log Phase
Context
A document-processing service writes one compact record for each work cycle. Each record contains a lowercase period label and the ordinal day within that period. The service uses a repeating set of four phase categories, with a threshold that advances the category near the end of each period.
Problem
Implement a function that returns the category assigned to a processing log record.
The period label is one of four values: alpha, beta, gamma, or delta. Begin with the default category for that period:
- alpha starts in draft
- beta starts in review
- gamma starts in publish
- delta starts in archive
Then apply the period's transition rule. If the day is at least the inclusive threshold, advance to the next category in the cycle draft, review, publish, archive, draft:
- alpha transitions at day 20
- beta transitions at day 15
- gamma transitions at day 10
- delta transitions at day 25
Return the resulting category as a lowercase string. Every supplied period-day pair is valid, and exactly one category must be returned.
Examples
day = 8period = "alpha""draft"day = 15period = "beta""publish"day = 22period = "gamma""archive"Constraints
4 <= len(period) <= 5period: alphabet lowercase1 <= day <= 31period contains only lowercase letters.- Types:
periodis str,dayis int; result is str
Function signature
def classify_log_phase(period: str, day: int) -> str
periodstr- The lowercase label of the processing period: alpha, beta, gamma, or delta.
dayint- The ordinal day within the selected period.
- returns str
- The lowercase processing category after applying the period default and any inclusive threshold transition.
Adapted from MBPP problem task_159 (CC BY 4.0). Rewritten, extended and verified by Iksha.
Notes
- The four allowed period labels are alpha, beta, gamma, and delta.
- Threshold comparisons are inclusive, so the threshold day itself transitions.