human
Total number of different staircase that can made from N boxes | Function to find the total number of different staircase that can made from N boxes.
DP table , there are two states . First describes the number of boxes and second describes the step.
Initialize all the elements of the table to zero.
Base case.
When step is equal to 2.
When step is greater than 2.
Count the total staircase from all the steps.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to total number of different staircase that can made from N boxes and the other steps required.
 def countStaircases ( N ) :
	memo = [ [ 0 for x in range ( N + 5 ) ] for y in range ( N + 5 ) ]
	for i in range ( N + 1 ) :
		for j in range ( N + 1 ) :
			memo [ i ] [ j ] = 0
	memo [ 3 ] [ 2 ] = memo [ 4 ] [ 2 ] = 1
	for i in range ( 5 , N + 1 ) :
		for j in range ( 2 , i + 1 ) :
			if ( j == 2 ) :
				memo [ i ] [ j ] = memo [ i - j ] [ j ] + 1
			else :
				memo [ i ] [ j ] = ( memo [ i - j ] [ j ] + memo [ i - j ] [ j - 1 ] )
	answer = 0
	for i in range ( 1 , N + 1 ) :
		answer = answer + memo [ N ] [ i ]
	return answer
if __name__ == " _ _ main _ _ " :
	N = 7
	print ( countStaircases ( N ) )