Calculate all Combinations
n = len ( S ) ; NEW_LINE choose [ 0 ] [ 0 ] = 1 ; NEW_LINE for i in range ( 1 , ( n // 2 ) + 1 ) : NEW_LINE INDENT choose [ i ] [ 0 ] = 1 ; NEW_LINE for j in range ( 1 , i + 1 ) : NEW_LINE INDENT choose [ i ] [ j ] = choose [ i - 1 ] [ j ] + choose [ i - 1 ] [ j - 1 ] ; NEW_LINE DEDENT DEDENT return calc ( 0 , n - 1 , S ) ; NEW_LINE