Compute the grid starting from the bottom - left corner
i = n - 1 NEW_LINE while ( i >= 0 ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT if ( j == 0 or i == n - 1 ) : NEW_LINE INDENT a [ i ] [ j ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT a [ i ] [ j ] = a [ i ] [ j - 1 ] + a [ i + 1 ] [ j ] NEW_LINE DEDENT DEDENT i -= 1 NEW_LINE DEDENT