Answer to Question #292071 in Python for Minimal absolute d

Question #292071

there are N pyramids in a line.you are given their Heights as a list of integers. write a program to print the minimum absolute difference between the heights of any two different pyramids.

1
Expert's answer
2022-01-30T16:05:42-0500
def minimum_absolute_difference(heights: list):
    sorted_heights = sorted(heights)
    return min([sorted_heights[i] - sorted_heights[i - 1] for i in range(1, len(heights))])

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS