human
Pyramid form ( increasing then decreasing ) consecutive array using reduce operations | Returns minimum cost to form a pyramid.
Store the maximum possible pyramid height.
Maximum height at start is 1.
For each position calculate maximum height.
Maximum height at end is 1.
For each position calculate maximum height.
Find minimum possible among calculated values.
Find maximum height of pyramid.
Calculate cost of this pyramid.
Calculate cost of left half.
Calculate cost of right half.
Driver Code"
Solution in Python:

What is a code to pyramid form ( increasing then decreasing ) consecutive array using reduce operations and the other steps required?
assistant
#Here is code to pyramid form ( increasing then decreasing ) consecutive array using reduce operations and the other steps required.
 def minPyramidCost ( arr : list , N ) :
	left = [ 0 ] * N
	right = [ 0 ] * N
	left [ 0 ] = min ( arr [ 0 ] , 1 )
	for i in range ( 1 , N ) :
		left [ i ] = min ( arr [ i ] , min ( left [ i - 1 ] + 1 , i + 1 ) )
	right [ N - 1 ] = min ( arr [ N - 1 ] , 1 )
	for i in range ( N - 2 , - 1 , - 1 ) :
		right [ i ] = min ( arr [ i ] , min ( right [ i + 1 ] + 1 , N - i ) )
	tot = [ 0 ] * N
	for i in range ( N ) :
		tot [ i ] = min ( right [ i ] , left [ i ] )
	max_ind = 0
	for i in range ( N ) :
		if tot [ i ] > tot [ max_ind ] :
			max_ind = i
	cost = 0
	height = tot [ max_ind ]
	for x in range ( max_ind , - 1 , - 1 ) :
		cost += arr [ x ] - height
		if height > 0 :
			height -= 1
	height = tot [ max_ind ] - 1
	for x in range ( max_ind + 1 , N ) :
		cost += arr [ x ] - height
		if height > 0 :
			height -= 1
	return cost
if __name__ == " _ _ main _ _ " :
	arr = [ 1 , 2 , 3 , 4 , 2 , 1 ]
	N = len ( arr )
	print ( minPyramidCost ( arr , N ) )