Just another day in the world of Minecraft, Steve is working on his new project -- building a beacon pyramid in front of his house.

![Beacon pyramid](http://www.minecraft101.net/reference/images/beacon_pyramid_thb.jpg)

Steve has already obtained the beacon (the glass wrapped blue thingy on the top), he just needs to build the pyramid. Each level of the pyramid is built using one of the following four kinds of block: gold, diamond, emerald, and iron. Since these four kinds of blocks are relatively hard to collect, Steve needs to know exactly how many of each kind is required to build a pyramid of level N.

Assume that the top level of the pyramid uses gold blocks, the second level uses diamond blocks, the third level uses emerald blocks, the fourth level uses iron blocks, and the fifth level uses gold blocks, etc. (if you are a Minecraft player, you know it's not neccessary the right way to build the pyramid. Let's just assume it is for the sake of this kata ;-))

Implement a function that takes one argument which is the number of levels of the pyramid, and returns an object of the form: `{total: 9, gold: 9, diamond: 0, emerald: 0, iron: 0}`.

---

To all the Minecraft players out there: 
feel free to expand this series or let me know if you have any ideas related to Minecraft that can be turned into codewars puzzles. Some ideas I have that might potentially be turned into katas:

* distance traveled in real world vs. in Nether
* shortest path problems related to mining diamonds/gold/goodies that appears in different levels under ground
* growth of animal population from breeding
* redstone stuff?!

If you do end up expanding this series, please send me a link of your kata so I can check it out and include a link to your kata here :-)

* [Minecraft Series #2: Minimum amount of fuel needed to get some iron ingots](https://www.codewars.com/kata/minecraft-series-number-2-minimum-amount-of-fuel-needed-to-get-some-iron-ingots/ruby)
* [Minecraft Series #3: Lava is amazing! ](https://www.codewars.com/kata/583a23d40cf946ec380002c2)
* [Minecraft Series #4: Lava is amazing, however...](https://www.codewars.com/kata/583a6b0b171f3a3c3f0003e3)

Difficulty: EASY

Starter code:
def blocks_to_collect(level):
	

Solutions:
def blocks_to_collect(level):
	answer = {'total': sum([(i + 3 + i) ** 2 for i in range(level)]), 'gold': sum([(i + 3 + i) ** 2 for i in range(0, level, 4)]), 'diamond': sum([(i + 3 + i) ** 2 for i in range(1, level, 4)]), 'emerald': sum([(i + 3 + i) ** 2 for i in range(2, level, 4)]), 'iron': sum([(i + 3 + i) ** 2 for i in range(3, level, 4)])}
	return answer


from itertools import count, cycle, islice
BLOCKS = ['gold', 'diamond', 'emerald', 'iron']

def blocks_to_collect(level):
	result = dict.fromkeys(BLOCKS, 0)
	for (block, n) in zip(islice(cycle(BLOCKS), level), count(3, step=2)):
		result[block] += n ** 2
	return {**result, 'total': sum(result.values())}


def blocks_to_collect(height):
	stuff = [0, 0, 0, 0]
	for level in range(height):
		stuff[level % 4] += (2 * level + 3) ** 2
	return dict(list(zip(('gold', 'diamond', 'emerald', 'iron', 'total'), stuff + [sum(stuff)])))


def blocks_to_collect(level):
	beacon = {x: 0 for x in 'total gold diamond emerald iron'.split(' ')}
	for l in range(1, level + 1):
		mode = 'gold diamond emerald iron'.split(' ')[(l - 1) % 4]
		blocks = (2 * l + 1) ** 2
		beacon['total'] += blocks
		beacon[mode] += blocks
	return beacon


L = ['gold', 'diamond', 'emerald', 'iron']

def blocks_to_collect(level):
	D = {'total': 0, 'gold': 0, 'diamond': 0, 'emerald': 0, 'iron': 0}
	for (i, x) in enumerate(range(3, 2 * level + 2, 2)):
		D[L[i % 4]] += x ** 2
	D['total'] = level + 4 * level * (level + 1) * (level + 2) // 3
	return D


def blocks_to_collect(l):
	t = l * (4 * l * (l + 3) + 11) // 3
	g = (l + 3) // 4 * (8 * ((l + 3) // 4) * (8 * ((l + 3) // 4) - 3) - 13) // 3
	d = (l + 2) // 4 * (8 * ((l + 2) // 4) * (8 * ((l + 2) // 4) + 3) - 13) // 3
	e = (l + 1) // 4 * (8 * ((l + 1) // 4) * (8 * ((l + 1) // 4) + 9) + 11) // 3
	i = l // 4 * (8 * (l // 4) * (8 * (l // 4) + 15) + 59) // 3
	return {'total': t, 'gold': g, 'diamond': d, 'emerald': e, 'iron': i}


def blocks_to_collect(x):
	return {'total': (4 * x ** 3 + 12 * x ** 2 + 11 * x) // 3, 'gold': (64 * (1 + (x - 1) // 4) ** 3 - 24 * (1 + (x - 1) // 4) ** 2 - 13 * (1 + (x - 1) // 4)) // 3, 'diamond': (64 * (1 + (x - 2) // 4) ** 3 + 24 * (1 + (x - 2) // 4) ** 2 - 13 * (1 + (x - 2) // 4)) // 3, 'emerald': (64 * (1 + (x - 3) // 4) ** 3 + 72 * (1 + (x - 3) // 4) ** 2 + 11 * (1 + (x - 3) // 4)) // 3, 'iron': (64 * (1 + (x - 4) // 4) ** 3 + 120 * (1 + (x - 4) // 4) ** 2 + 59 * (1 + (x - 4) // 4)) // 3}


from itertools import cycle

def blocks_to_collect(level):
	materials = cycle(('gold', 'diamond', 'emerald', 'iron'))
	res = {'total': 0, 'gold': 0, 'diamond': 0, 'emerald': 0, 'iron': 0}
	for x in range(3, 2 * level + 2, 2):
		material = next(materials)
		res[material] += x ** 2
		res['total'] += x ** 2
	return res


def blocks_to_collect(level):
	seq = ['gold', 'diamond', 'emerald', 'iron']
	result = {'total': 0, 'gold': 0, 'diamond': 0, 'emerald': 0, 'iron': 0}
	for i in range(1, level + 1):
		n = (i * 2 + 1) ** 2
		result['total'] += n
		result[seq[(i - 1) % len(seq)]] += n
	return result


def blocks_to_collect(level):
	(order, output, count) = (['gold', 'diamond', 'emerald', 'iron'], {'total': 0, 'gold': 0, 'diamond': 0, 'emerald': 0, 'iron': 0}, 3)
	for loop in range(level):
		square = count * count
		output['total'] += square
		output[order[loop % 4]] += square
		count += 2
	return output