How many ways can a row measuring fifty units in length be filled?
Here's what I've wrote so far in python:
def prob(blocksize,colorsize):
solutions = 1
for position in range(0,blocksize-colorsize+1):
#print('\n',"New position:",position)
for blocklength in range(colorsize,blocksize-position+1):
#print("P:",position,"S:",blocklength,"Res:",solutions)
solutions+=prob(blocksize-position-blocklength-1,colorsize)
#print("Blocksize:",blocksize-position-blocklength-1,"Colorsize:",colorsize,)
return solutions
print(prob(10,3))
Can someone please explain to me how this recursive function works please. I've been studying recursive function and I understood how it works.The problem is that I cannot understand how the speffic one works.

New Topic/Question
Reply



MultiQuote


|