Pyramid Algorithm