You've came to visit your grandma and she straight away found you a job - her Christmas tree needs decorating!

She first shows you a tree with an identified number of branches, and then hands you a some baubles (or loads of them!).

You know your grandma is a very particular person and she would like the baubles to be distributed in the orderly manner. You decide the best course of action would be to put the same number of baubles on each of the branches (if possible) or add one more bauble to some of the branches - starting from the beginning of the tree. 

In this kata you will return an array of baubles on each of the branches.

For example: 

10 baubles, 2 branches: [5,5]
5 baubles, 7 branches: [1,1,1,1,1,0,0]
12 baubles, 5 branches: [3,3,2,2,2]

The numbers of branches and baubles will be always greater or equal to 0.
If there are 0 branches return: "Grandma, we will have to buy a Christmas tree first!".

Good luck - I think your granny may have some minced pies for you if you do a good job!

Source: codewars | Difficulty: EASY
Tags: Data structures

Starter code: def baubles_on_tree(baubles, branches):
	

Solutions:
def baubles_on_tree(baubles, branches):
	if not branches:
		return 'Grandma, we will have to buy a Christmas tree first!'
	(d, r) = divmod(baubles, branches)
	return [d + 1] * r + [d] * (branches - r)


def baubles_on_tree(baubles, branches):
	if branches == 0:
		x = 'Grandma, we will have to buy a Christmas tree first!'
		return x
	x = baubles // branches
	list_of_baubles = [x] * branches
	z = baubles % branches
	y = z - 1
	if z != 0:
		for i in range(z):
			list_of_baubles[i] = list_of_baubles[i] + 1
	return list_of_baubles


def baubles_on_tree(baubles, branches):
	return [baubles // branches + (i < baubles % branches) for i in range(branches)] if branches else 'Grandma, we will have to buy a Christmas tree first!'


def baubles_on_tree(baubles, branches):
	if not branches:
		return 'Grandma, we will have to buy a Christmas tree first!'
	extra = baubles - baubles // branches * branches
	l = []
	for i in range(branches):
		l.append(baubles // branches + 1 * (extra > 0))
		extra -= 1
	return l


baubles_on_tree = lambda b, c: [(b + c - i - 1) // c for i in range(c)] if c else 'Grandma, we will have to buy a Christmas tree first!'


from itertools import cycle, islice
from collections import Counter

def baubles_on_tree(baubles, branches):
	return [Counter(islice(cycle(range(branches)), baubles))[x] for x in range(branches)] or 'Grandma, we will have to buy a Christmas tree first!'


from math import ceil

def baubles_on_tree(baubles, branches):
	return [ceil((baubles - i) / branches) for i in range(0, branches)] if branches > 0 else 'Grandma, we will have to buy a Christmas tree first!'


def baubles_on_tree(baubles, branches):
	if not branches:
		return 'Grandma, we will have to buy a Christmas tree first!'
	(d, m) = divmod(baubles, branches)
	return [d * (i <= branches) + (i <= m - 1) for i in range(branches)]