We are still with squared integers.

Given 4 integers `a, b, c, d` we form the sum of the squares of `a` and `b`
and then the sum of the squares of `c` and `d`. We multiply the two sums hence a number `n` and we try to
decompose `n` in a sum of two squares `e` and `f` (e and f integers >= 0) so that `n = e² + f²`. 

More: `e` and `f` must result only from sums (or differences) of products between on the one hand `(a, b)` and on the other `(c, d)` each of `a, b, c, d` taken only once. 
For example, 
prod2sum(1, 2, 1, 3) should return [[1, 7], [5, 5]]) 
because 
```
1==1*3-1*2
7==2*3+1*1
5==1*2+1*3
```
Suppose we have `a = 1, b = 2, c = 1, d = 3`. First we calculate the sums 
`1² + 2² = 5 and 1² + 3² = 10` hence `n = 50`.



`50 = 1² + 7² or 50 = 7² + 1²` (we'll consider that these two solutions are the same)
or `50 = 5² + 5²`. 

The return of our function will be an array of subarrays (in C an array of Pairs) sorted on the first elements of the subarrays. In each subarray the lower element should be the first.

`prod2sum(1, 2, 1, 3) should return [[1, 7], [5, 5]]`

`prod2sum(2, 3, 4, 5) should return  [[2, 23], [7, 22]]`

because `(2² + 3²) * (4² + 5²) = 533 = (7² + 22²) = (23² + 2²)`

`prod2sum(1, 2, 2, 3) should return  [[1, 8], [4, 7]]`

`prod2sum(1, 1, 3, 5) should return  [[2, 8]]` (there are not always 2 solutions).

##Hint
Take a sheet of paper and with a bit of algebra try to write the product of squared numbers in another way.

Difficulty: EASY
Starter code: def prod2sum(a, b, c, d):
	

Solutions:
def prod2sum(a, b, c, d):
	e = sorted([abs(a * d - b * c), abs(a * c + b * d)])
	f = sorted([abs(a * c - b * d), abs(a * d + b * c)])
	if e == f:
		return [e]
	else:
		return sorted([e, f])


def prod2sum(a, b, c, d):
	r1 = sorted([abs(a * c - b * d), abs(a * d + b * c)])
	r2 = sorted([abs(a * c + b * d), abs(a * d - b * c)])
	return sorted([r1, r2]) if r1 != r2 else [r1]


prod2sum = lambda a, b, c, d: sorted([list(i) for i in {tuple(sorted(map(abs, [a * d + b * c, a * c - b * d]))), tuple(sorted(map(abs, [a * c + b * d, abs(a * d - b * c)])))}])


def prod2sum(a, b, c, d):
	num = [a, b, c, d]
	if sorted([abs(num[0] * num[2] - num[1] * num[3]), abs(num[0] * num[3] + num[1] * num[2])]) == sorted([num[0] * num[3] - num[1] * num[2], num[0] * num[2] + num[1] * num[3]]):
		return [sorted([abs(num[0] * num[3] + num[1] * num[2]), abs(num[0] * num[2] - num[1] * num[3])])]
	elif sorted([abs(num[0] * num[3] - num[1] * num[2]), abs(num[0] * num[2] + num[1] * num[3])])[0] < sorted([abs(num[0] * num[2] - num[1] * num[3]), abs(num[0] * num[3] + num[1] * num[2])])[0]:
		return [sorted([abs(num[0] * num[3] - num[1] * num[2]), abs(num[0] * num[2] + num[1] * num[3])]), sorted([abs(num[0] * num[2] - num[1] * num[3]), abs(num[0] * num[3] + num[1] * num[2])])]
	else:
		return [sorted([abs(num[0] * num[2] - num[1] * num[3]), abs(num[0] * num[3] + num[1] * num[2])]), sorted([abs(num[0] * num[3] - num[1] * num[2]), abs(num[0] * num[2] + num[1] * num[3])])]


def chsgn(k):
	r = []
	for x in k:
		if x < 0:
			r.append(-x)
		else:
			r.append(x)
	return r

def prod2sum(a, b, c, d):
	e1 = a * c + b * d
	f1 = a * d - b * c
	e2 = a * c - b * d
	f2 = a * d + b * c
	k = chsgn([e1, e2, f1, f2])
	e1 = k[0]
	e2 = k[1]
	f1 = k[2]
	f2 = k[3]
	if e1 == f2 and f1 == e2 or (e1 == e2 and f1 == f2):
		res = [[min(e1, f1), max(e1, f1)]]
	else:
		res = [[min(e1, f1), max(e1, f1)]]
		res.append([min(e2, f2), max(e2, f2)])
	res = sorted(res, key=lambda x: x[0])
	return res


def prod2sum(a, b, c, d):
	result = map(sorted, [map(abs, [a * d - b * c, a * c + b * d]), map(abs, [b * d - a * c, b * c + a * d])])
	return sorted(result, key=lambda x: x[0])[:2 - (a == b or b == 0)]


def prod2sum(a, b, c, d):
	l1 = sorted([abs(a * c + b * d), abs(a * d - b * c)])
	l2 = sorted([abs(a * c - b * d), abs(a * d + b * c)])
	if l1 == l2:
		return [l1]
	else:
		return sorted([l1, l2])


def prod2sum(a, b, c, d):
	hi = sorted([abs(a * c + b * d), abs(a * d - b * c)])
	hello = sorted([abs(a * c - b * d), abs(a * d + b * c)])
	if hi == hello:
		return [hi]
	else:
		return sorted([hi, hello])


def as_pair(z):
	pos_int = lambda x: abs(int(x))
	return sorted(map(pos_int, [z.real, z.imag]))

def prod2sum(a, b, c, d):
	z = complex(a, b)
	w = complex(c, d)
	results = list(map(as_pair, [z * w, z * w.conjugate()]))
	if results[1] == results[0]:
		results.pop()
	return sorted(results)