Pyramid form (increasing then decreasing) consecutive array using reduce operations
We have N (where N > 2) stones of various heights laid out in a row. The task is to make a pyramid from a given array of stones. In a pyramid, the height of the stones starts from 1, increase by 1, until it reaches some value x, then decreases by 1 until it reaches 1 again i.e. the stones should be 1, 2, 3, 4...x - 1, x, x - 1, x - 2 ... 1. All