Minimal Absolute Difference
There are N pyramids in a line.You are given their heights as a list of integers.Write a program to find the minimum absolute difference between the heights of any two different pyramids.
Input
The input is a single line containing space-separated integers.
Output
The output should be a single line containing the minimum absolute difference of any two different pyramid heights.
Explaanation
Given Pyramid heights are 7 1 5.
The absolute difference between the heights of any two different pyramids are
import statistics
def MAD(list1):
j = 0
mean = statistics.mean(list1)
for i in list1:
dev = abs(i-mean)
j = j + dev
return j
MAD([7, 1, 5])
6.666666666666667
Comments
Leave a comment