Implementation of circus piramid problem