It's tricky keeping track of who is owed what when spending money in a group. Write a function to balance the books.

* The function should take one parameter: an object/dict with two or more name-value pairs which represent the members of the group and the amount spent by each.
* The function should return an object/dict with the same names, showing how much money the members should pay or receive.

**Further points:**

* The values should be positive numbers if the person should receive money from the group, negative numbers if they owe money to the group.
* If value is a decimal, round to two decimal places.
 
Translations and comments (and upvotes!) welcome.

### Example

3 friends go out together: A spends £20, B spends £15, and C spends £10. The function should return an object/dict showing that A should receive £5, B should receive £0, and C should pay £5.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Starter code: def split_the_bill(x):
	

Solutions:
def split_the_bill(x):
	diff = sum(x.values()) / float(len(x))
	return {k: round(x[k] - diff, 2) for k in x}


def split_the_bill(spendings):
	fair_amount = sum(spendings.values()) / float(len(spendings))
	return {name: round(amount - fair_amount, 2) for (name, amount) in spendings.items()}


def split_the_bill(d):
	avg = sum(d.values()) / len(d)
	return {n: round(v - avg, 2) for (n, v) in d.items()}


def split_the_bill(x):
	bill = float(sum((amount for amount in x.values()))) / len(x)
	return {person: round(amount - bill, 2) for (person, amount) in x.items()}


def split_the_bill(group):
	mean = sum(group.values()) / float(len(group))
	return {k: round(v - mean, 2) for (k, v) in group.items()}


def split_the_bill(x):
	m = sum(x.values()) / float(len(x))
	return {k: round(v - m, 2) for (k, v) in x.items()}


def split_the_bill(x):
	avg = 1.0 * sum(x.values()) / len(x)
	return {key: round(value - avg, 2) for (key, value) in x.items()}


def split_the_bill(x):
	perperson = 1.0 * sum(x.values()) / len(x)
	for (name, val) in x.items():
		x[name] = round(val - perperson, 2)
	return x


def split_the_bill(x):
	avg = sum(x.values()) / float(len(x))
	group = {}
	for key in x:
		group[key] = round(x[key] - avg, 2)
	return group