Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save imedadel/68fe2f32e9dbc5f3f0497219a0f7fa18 to your computer and use it in GitHub Desktop.

Select an option

Save imedadel/68fe2f32e9dbc5f3f0497219a0f7fa18 to your computer and use it in GitHub Desktop.
def minimumAbsoluteDifference(arr):
uniq = sorted(list(set(arr)))
minVal = uniq[-1]
for i in range(len(uniq)-1):
newMin = min([abs(x-uniq[i]) for x in uniq[i+1:]])
if minVal > newMin:
minVal = newMin
return minVal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment