Given an array (ints) of n integers, find three integers in arr such that the sum is closest to a given number (num), target.

Return the sum of the three integers. 
You may assume that each input would have exactly one solution.

Example:

Note: your solution should not modify the input array.

Difficulty: EASY
Starter code: def closest_sum(ints, num):
	

Solutions:
from itertools import combinations

def closest_sum(ints, num):
	return sum(min(combinations(ints, 3), key=lambda a: abs(num - sum(a))))


from itertools import combinations

def closest_sum(ints, num):
	ss = map(sum, combinations(ints, 3))
	return min(ss, key=lambda x: abs(x - num))


from itertools import combinations

def closest_sum(arr, target):
	return min(map(sum, combinations(arr, 3)), key=lambda s: abs(target - s))


def closest_sum(i, ii):
	print(i)
	print(ii)
	iii = len(i)
	iiiiiii = 2.6406429642573826e+32
	for iiii in range(iii):
		for iiiii in range(iii):
			for iiiiii in range(iii):
				if iiii != iiiii and iiiii != iiiiii and (iiiiii != iiii):
					if abs(i[iiii] + i[iiiii] + i[iiiiii] - ii) < abs(iiiiiii - ii):
						iiiiiii = i[iiii] + i[iiiii] + i[iiiiii]
	return iiiiiii


closest_sum = lambda a, n: min(map(sum, __import__('itertools').combinations(a, 3)), key=lambda c: abs(c - n))


from itertools import permutations
closest_sum = lambda s, n: min([sum(i) for i in permutations(s, 3)], key=lambda x: abs(x - n))


def A(arr, a, b, c, L, T):
	if c < L:
		T.append(arr[a] + arr[b] + arr[c])
	if a == L - 2:
		return 0
	elif b == L - 2:
		return A(arr, a + 1, a + 2, a + 3, L, T)
	elif c == L - 1:
		return A(arr, a, b + 1, b + 2, L, T)
	return A(arr, a, b, c + 1, L, T)

def closest_sum(ints, num):
	print((num, ints))
	T = []
	A(ints, 0, 1, 2, len(ints), T)
	print(T)
	if num in T:
		return num
	else:
		(l, h) = (num, num)
		while True:
			l -= 1
			h += 1
			if l in T and h in T:
				return l if T.index(l) < T.index(h) else h
			if l in T:
				return l
			if h in T:
				return h


import itertools

def closest_sum(ints, num):
	res = ints[:3]
	comb = list(itertools.combinations(ints, 3))
	for i in comb:
		if abs(num - sum(i)) < abs(num - sum(res)):
			res = [_ for _ in i]
	return sum(res)