<qiyuangong>018_4Sum_2.py
def fourSum( nums, target):
    index_pairs = dict()
    combos = dict()
    n = len(nums)
    for i in range(0,n):
        for j in range(i+1,n):
            sum = nums[i] + nums[j]
            if index_pairs.get(target - sum) is not None:
                for pair in index_pairs[target - sum]:
                    if i != pair[0] and i != pair[1] and j != pair[0] and j != pair[1]: 
                        combo = sorted((nums[i], nums[j], nums[pair[0]], nums[pair[1]])) 
                        combos[tuple(combo)] = True
            if index_pairs.get(sum) is not None:
                index_pairs[sum].append((i,j))
            else:
                index_pairs[sum] = [(i,j)]
    return combos.keys()
def sample_funcname ( var_0 , var_1 ) :
    var_3 = dict ( )
    var_4 = dict ( )
    var_6 = len ( var_0 )
    for var_9 in range ( 0 , var_6 ) :
        for var_11 in range ( var_9 + 1 , var_6 ) :
            var_12 = var_0 [ var_9 ] + var_0 [ var_11 ]
            if var_3.get ( var_1 - var_12 ) is not None :
                for var_15 in var_3 [ var_1 - var_12 ] :
                    if var_9 != var_15 [ 0 ] and var_9 != var_15 [ 1 ] and var_11 != var_15 [ 0 ] and var_11 != var_15 [ 1 ] :
                        var_17 = sorted ( ( var_0 [ var_9 ] , var_0 [ var_11 ] , var_0 [ var_15 [ 0 ] ] , var_0 [ var_15 [ 1 ] ] ) )
                        var_4 [ tuple ( var_17 ) ] = True
            if var_3.get ( var_12 ) is not None :
                var_3 [ var_12 ].append ( ( var_9 , var_11 ) )
            else :
                var_3 [ var_12 ] = [ ( var_9 , var_11 ) ]
    return var_4.keys ( )
