The task counts paths to position n, every final move has one of two fixed lengths, and paths ending with different final moves are disjoint.
Keep true
Before each iteration, previous and current are consecutive recurrence values. Parallel assignment shifts current into previous and stores previous + current as the complete count for the next step.
Reuse it
Classify solutions by their final decision: if every state can only arrive from a fixed small set of predecessor states, add those disjoint counts and retain only the dependency horizon.
Read it this way: For n = 5, previous = 0 and current = 1 represent the two values needed before the first loop update. Step through the frames to watch the state change. The last frame shows the answer or the stopping condition.
Pattern: DP with the last two answers.
Simple idea: Every path to the current step comes from one step back or two steps back.
This is the Fibonacci rule.
def climb_stairs(step_count: int) -> int: previous, current = 0, 1 for _ in range(step_count): previous, current = current, previous + current return current