>When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process  --myjinxin2015 said

# Description:
 In kindergarten, the teacher gave the children some candies. The number of candies each child gets is not always the same. Here is an array `candies`(all elements are positive integer). It's the number of candy for each child:
 ```
 candies = [10,2,8,22,16,4,10,6,14,20]
 ```
 The teacher asked the children to form a circle and play a game: Each child gives half of his candies to the child on his right(at the same time). If the number of children's candy is an odd number, the teacher will give him an extra candy, so that he can evenly distribute his candy. 
 
 Repeat such distribute process, until all the children's candies are equal in number.
 
 You should return two numbers: 1.How many times of distribution; 2. After the game, the number of each child's candy. Returns the result using an array that contains two elements.
 
  
# Some examples:

```
      candies = [ 1,2,3,4,5 ]
Distribution 1: [ 4,2,3,4,5 ]
Distribution 2: [ 5,3,3,4,5 ]
Distribution 3: [ 6,5,4,4,5 ]
Distribution 4: [ 6,6,5,4,5 ]
Distribution 5: [ 6,6,6,5,5 ]
Distribution 6: [ 6,6,6,6,6 ]
So, we need return: [6,6]

distributionOfCandy([1,2,3,4,5]) === [6,6]

       candies = [ 10,  2,  8, 22, 16,  4, 10,  6, 14, 20 ]
distribution  1: [ 15,  6,  5, 15, 19, 10,  7,  8, 10, 17 ]
distribution  2: [ 17, 11,  6, 11, 18, 15,  9,  8,  9, 14 ]
distribution  3: [ 16, 15,  9,  9, 15, 17, 13,  9,  9, 12 ]
distribution  4: [ 14, 16, 13, 10, 13, 17, 16, 12, 10, 11 ]
distribution  5: [ 13, 15, 15, 12, 12, 16, 17, 14, 11, 11 ]
distribution  6: [ 13, 15, 16, 14, 12, 14, 17, 16, 13, 12 ]
distribution  7: [ 13, 15, 16, 15, 13, 13, 16, 17, 15, 13 ]
distribution  8: [ 14, 15, 16, 16, 15, 14, 15, 17, 17, 15 ]
distribution  9: [ 15, 15, 16, 16, 16, 15, 15, 17, 18, 17 ]
distribution 10: [ 17, 16, 16, 16, 16, 16, 16, 17, 18, 18 ]
distribution 11: [ 18, 17, 16, 16, 16, 16, 16, 17, 18, 18 ]
distribution 12: [ 18, 18, 17, 16, 16, 16, 16, 17, 18, 18 ]
distribution 13: [ 18, 18, 18, 17, 16, 16, 16, 17, 18, 18 ]
distribution 14: [ 18, 18, 18, 18, 17, 16, 16, 17, 18, 18 ]
distribution 15: [ 18, 18, 18, 18, 18, 17, 16, 17, 18, 18 ]
distribution 16: [ 18, 18, 18, 18, 18, 18, 17, 17, 18, 18 ]
distribution 17: [ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 ]
So, we need return: [17,18]

distributionOfCandy([10,2,8,22,16,4,10,6,14,20]) === [17,18]

```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Ad-hoc

Starter code: def distribution_of_candy(candies):
	

Solutions:
def distribution_of_candy(candies):
	steps = 0
	while len(set(candies)) > 1:
		candies = [(a + 1) // 2 + (b + 1) // 2 for (a, b) in zip(candies, candies[-1:] + candies)]
		steps += 1
	return [steps, candies.pop()]


def distribution_of_candy(candies):
	n = 0
	while any((c != candies[0] for c in candies)):
		n += 1
		half = [(c + 1) // 2 for c in candies]
		candies = [a + b for (a, b) in zip(half, half[-1:] + half[:-1])]
	return [n, candies[0]]


def distribution_of_candy(candies):
	turn = 0
	while len(set(candies)) > 1:
		candies = [(m + m % 2) // 2 + (n + n % 2) // 2 for (m, n) in zip(candies, candies[-1:] + candies[:-1])]
		turn += 1
	return [turn, candies[0]]


def distribution_of_candy(candies):
	r = 0
	while len(set(candies)) > 1:
		r += 1
		candies = [(c + 1) // 2 + (candies[i - 1] + 1) // 2 for (i, c) in enumerate(candies)]
	return [r, candies[0]]


def distribution_of_candy(candies):
	if len(candies) == 1:
		return [0, candies[0]]
	(c, lst) = (0, candies)
	while True:
		lst = [i // 2 if i % 2 == 0 else (i + 1) // 2 for i in lst]
		lst2 = lst[-1:] + lst[:-1]
		lst = [i + j for (i, j) in zip(lst, lst2)]
		c += 1
		if len(set(lst)) == 1:
			return [c, lst[0]]


from itertools import count

def distribution_of_candy(a):
	for i in count():
		if all((x == a[0] for x in a)):
			return [i, a[0]]
		a = [x + x % 2 for x in a]
		a = [(x + y) // 2 for (x, y) in zip(a, a[1:] + [a[0]])]


def distribution_of_candy(c):
	i = 0
	while min(c) != max(c):
		i += 1
		a = [(v + v % 2) // 2 for v in c]
		c = [x + y for (x, y) in zip(a, a[-1:] + a)]
	return [i, c[0]]


def distribution_of_candy(candies):
	candies_upd = candies
	cnt = 0
	if len(candies) == 1:
		return [0, candies[0]]
	while candies.count(candies[0]) < len(candies) or candies_upd.count(candies_upd[0]) < len(candies_upd):
		if cnt > 0:
			candies = candies_upd
		candies_upd = []
		for i in range(len(candies)):
			new = candies[i]
			if candies[i] % 2 != 0:
				new += 1
			new -= new / 2
			if i == 0:
				new += round(candies[-1] / 2 + 0.1)
			else:
				new += round(candies[i - 1] / 2 + 0.1)
			candies_upd.append(new)
		cnt += 1
	return [cnt - 1, candies[0]]


def distribution_of_candy(arr):
	c = 0
	while len(set(arr)) != 1:
		x = [(i + 1 if i % 2 else i) // 2 for i in arr[-1:] + arr[:-1]]
		arr = [(i + 1 if i % 2 else i) - (i + 1 if i % 2 else i) // 2 for i in arr]
		arr = [i + j for (i, j) in zip(arr, x)]
		c += 1
	return [c, arr.pop()]