List the first $$2n$$ positive integers, with $$n \in \mathbb{N}_0$$.

1, 2, 3, 4, 5, 6, 7, 8

Split these numbers arbitrarily into two groups of $$n$$ numbers, with half of the number going into the first group and the other half in the second group.

7, 1, 6, 4
2, 8, 5, 3

Arrange the numbers in the first group in ascending order, and the numbers in the second group in descending order.

1, 4, 6, 7
8, 5, 3, 2

Now if you compute the sum of the absolute values of the difference between each pair of numbers at corresponding positions in both groups, the sum will always equal $$n^2$$. \[|1 - 8| + |4 - 5| + |6 - 3| + |7 - 2| = 7 + 1 + 3 + 5 = 16 = n^2\] This identity was proven by Vyacheslav Proizvolov.

Assignment

In this assignment we represent a group of numbers as a tuple of integers. Your task:

Example

>>> split(8)
((7, 1, 6, 4), (2, 8, 5, 3))
>>> split(8, different=False)
((4, 4, 7, 3), (7, 1, 2, 3))
>>> split(3)
Traceback (most recent call last):
AssertionError: invalid length
>>> split(-3, different=True)
Traceback (most recent call last):
AssertionError: invalid length

>>> add((7, 1, 6, 4), (2, 8, 5, 3))
16
>>> add((4, 4, 7, 3), (7, 1, 2, 3))
13
>>> add((8, 3, 15), (27, 24, 5, 42))
Traceback (most recent call last):
AssertionError: groups must have equal length