Number of containers that can be filled in the given time | Matrix of containers ; Function to find the number of containers that will be filled in X seconds ; Container on top level ; If container gets filled ; Dividing the liquid equally in two halves ; Driver code
cont = [ [ 0 for i in range ( 1000 ) ] for j in range ( 1000 ) ] NEW_LINE def num_of_containers ( n , x ) : NEW_LINE INDENT count = 0 NEW_LINE cont [ 1 ] [ 1 ] = x NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in range ( 1 , i + 1 ) : NEW_LINE INDENT if ( cont [ i ] [ j ] >= 1 ) : NEW_LINE INDENT count += 1 NEW_LINE cont [ i + 1 ] [ j ] += ( cont [ i ] [ j ] - 1 ) / 2 NEW_LINE cont [ i + 1 ] [ j + 1 ] += ( cont [ i ] [ j ] - 1 ) / 2 NEW_LINE DEDENT DEDENT DEDENT print ( count ) NEW_LINE DEDENT n = 3 NEW_LINE x = 5 NEW_LINE num_of_containers ( n , x ) NEW_LINE