<qiyuangong>018_4Sum_1.py
def fourSum( nums, target):
    sort_nums = sorted(nums)
    ls = len(nums)
    res = {}
    pairs = {}
    for i in range(ls - 3):
        for j in range(i + 1, ls - 2):
            res_2 = sort_nums[i] + sort_nums[j]
            try:
                pairs[target - res_2].append([i, j])
            except KeyError:
                pairs[target - res_2] = [[i, j]]
    for key, temp in pairs.items():
        for pair in temp:
            j = pair[1] + 1
            k = ls - 1
            while j < k:
                current = sort_nums[j] + sort_nums[k]
                if current == key:
                    result = (sort_nums[pair[0]], sort_nums[pair[1]], sort_nums[j], sort_nums[k])
                    res[result] = True
                    j += 1
                elif current < key:
                    j += 1
                else:
                    k -= 1
    return res.keys()
def sample_funcname ( var_0 , var_1 ) :
    var_3 = sorted ( var_0 )
    var_5 = len ( var_0 )
    var_6 = { }
    var_7 = { }
    for var_10 in range ( var_5 - 3 ) :
        for var_13 in range ( var_10 + 1 , var_5 - 2 ) :
            var_14 = var_3 [ var_10 ] + var_3 [ var_13 ]
            try :
                var_7 [ var_1 - var_14 ].append ( [ var_10 , var_13 ] )
            except KeyError :
                var_7 [ var_1 - var_14 ] = [ [ var_10 , var_13 ] ]
    for var_18 , var_19 in var_7.items ( ) :
        for var_20 in var_19 :
            var_13 = var_20 [ 1 ] + 1
            var_21 = var_5 - 1
            while var_13 < var_21 :
                var_22 = var_3 [ var_13 ] + var_3 [ var_21 ]
                if var_22 == var_18 :
                    var_24 = ( var_3 [ var_20 [ 0 ] ] , var_3 [ var_20 [ 1 ] ] , var_3 [ var_13 ] , var_3 [ var_21 ] )
                    var_6 [ var_24 ] = True
                    var_13 += 1
                elif var_22 < var_18 :
                    var_13 += 1
                else :
                    var_21 -= 1
    return var_6.keys ( )
