Driver code
INDENT def countWays ( N , S ) : NEW_LINE INDENT dp = [ [ [ - 1 for k in range ( 2 ) ] for i in range ( N + 1 ) ] for j in range ( N + 1 ) ] NEW_LINE return parenthesis_count ( S , 0 , N - 1 , 1 , dp ) NEW_LINE DEDENT DEDENT symbols = " TTFT " NEW_LINE operators = " | & ^ " NEW_LINE S = " " NEW_LINE j = 0 NEW_LINE for i in range ( len ( symbols ) ) : NEW_LINE INDENT S = S + symbols [ i ] NEW_LINE if ( j < len ( operators ) ) : NEW_LINE INDENT S = S + operators [ j ] NEW_LINE j += 1 NEW_LINE DEDENT DEDENT