Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def absoluteValuesSumMinimization(a)
- x = 0
- y = 0
- sum = 0
- smallest = 0
- while (x < a.length)
- while (y < a.length)
- sum = sum + (a[y] - a[x]).abs
- y = y + 1
- end
- if sum < smallest or x == 0 then
- smallest = sum
- lowest_x = a[x]
- end
- x = x + 1
- y = 0
- sum = 0
- end
- return lowest_x
- end
Advertisement
Add Comment
Please, Sign In to add comment