Born a misinterpretation of [this kata](https://www.codewars.com/kata/simple-fun-number-334-two-beggars-and-gold/), your task here is pretty simple: given an array of values and an amount of beggars, you are supposed to return an array with the sum of what each beggar brings home, assuming they all take regular turns, from the first to the last.

For example: `[1,2,3,4,5]` for `2` beggars will return a result of `[9,6]`, as the first one takes `[1,3,5]`, the second collects `[2,4]`.

The same array with `3` beggars would have in turn have produced a better out come for the second beggar: `[5,7,3]`, as they will respectively take `[1,4]`, `[2,5]` and `[3]`.

Also note that not all beggars have to take the same amount of "offers", meaning that the length of the array is not necessarily a multiple of `n`; length can be even shorter, in which case the last beggars will of course take nothing (`0`).

***Note:*** in case you don't get why this kata is about *English* beggars, then you are not familiar on how religiously queues are taken in the kingdom ;)

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Complete search

Starter code: def beggars(values, n):
	

Solutions:
def beggars(values, n):
	return [sum(values[i::n]) for i in range(n)]


def beggars(a, n):
	return [sum(a[i::n]) for i in range(n)]


def beggars(values, n):
	if n == 0:
		return []
	i = 0
	take = []
	for x in range(n):
		take.append(0)
	for val in values:
		take[i % n] = take[i % n] + val
		i = i + 1
	return take


def beggars(values: list, n: int):
	if n < 1:
		return []
	beggars = [0] * n
	for (i, v) in enumerate(values):
		beggars[i % n] += v
	return beggars


def beggars(values, n):
	if n < 1:
		return []
	k = [0] * n
	for i in range(len(values)):
		k[i % n] += values[i]
	return k


def beggars(values, n):
	return [sum(values[k::n]) for k in range(n)]


def beggars(values, n):
	if n == 0:
		return []
	newe = list((0 for i in range(n)))
	count = 0
	for i in values:
		newe[count % n] += i
		count += 1
	return newe


def beggars(values, n):
	return [sum((values[i] for i in range(j, len(values), n))) for j in range(n)]


beggars = lambda values, n: [sum(values[i::n]) for i in range(n)]


def beggars(values, n):
	retList = [0] * n
	if not n:
		return []
	for (idx, i) in enumerate(values):
		retList[idx % n] += i
	return retList