$ ./guess_the_languageProblem Solving — fill the blank
Problem Solving — fill the blank · medium · #308

What goes in the blank?

# ways to climb n steps, 1 or 2 at a time
def ways(n):
    a, b = 1, 1
    for _ in range(n):
        a, b = b, a ____ b
    return a

Answer: + (also accepted: +)

ways(n) = ways(n-1) + ways(n-2), the Fibonacci recurrence kept in two rolling variables.
Play Problem Solving ▸