PracticeSimulation

Classify a Processing Log Phase

EasySimulationtraversalstate trackingcomparison Time not estimated Not started

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

Example 1
Input: day = 8period = "alpha"
Output: "draft"
Explanation: For {"period":"alpha","day":8}, the executed function returned "draft"; the trace records boundary_day 20 and category "draft".
Example 2
Input: day = 15period = "beta"
Output: "publish"
Explanation: For {"period":"beta","day":15}, the executed function returned "publish"; the trace records boundary_day 15 and category "publish".
Example 3
Input: day = 22period = "gamma"
Output: "archive"
Explanation: For {"period":"gamma","day":22}, the executed function returned "archive"; the trace records boundary_day 10 and category "archive".

Constraints

  • 4 <= len(period) <= 5
  • period: alphabet lowercase
  • 1 <= day <= 31
  • period contains only lowercase letters.
  • Types: period is str, day is int; result is str

Function signature

def classify_log_phase(period: str, day: int) -> str
period str
The lowercase label of the processing period: alpha, beta, gamma, or delta.
day int
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.
Approved · cc006-abs_613_v114 execution-verified tests
Code
Saved
Checking environment…Python SandboxLn 1, Col 1