I am kind of stuck on how to approach creating the recurrence for my piece of code, since we are going to have return statements that call the function twice or thrice, based on whether a stack has a blue plate. Any solution to this would be appreciated!
The Python code for the problem is shown below:
def stack_plates(n, color, has_blue_plate):
if n == 0:
return 1
if has_blue_plate:
return stack_plates(n-1, 'Blue', True) + \
stack_plates(n-1, 'Green', False)
else:
return stack_plates(n-1, 'Red', False) + \
stack_plates(n-1, 'Blue', True) + \
stack_plates(n-1, 'Green', False)