human
Write me a code to maximum height when coins are arranged in a triangle and the other steps required given the following:
Maximum height when coins are arranged in a triangle | Returns the square root of n . Note that the function.
We are using n itself as initial approximation This can definitely be improved.
e = 0.000001 e decides the accuracy level.
Method to find maximum height of arrangement of coins.
calculating portion inside the square root.
Driver code to test above method"
How can the above be solved in Python?
assistant
#Here is code to maximum height when coins are arranged in a triangle and the other steps required.
 def squareRoot ( n ) :
	x = n
	y = 1
	while ( x - y > e ) :
		x = ( x + y ) / 2
		y = n / x
	return x
def findMaximumHeight ( N ) :
	n = 1 + 8 * N
	maxH = ( - 1 + squareRoot ( n ) ) / 2
	return int ( maxH )
N = 12
print ( findMaximumHeight ( N ) )