Skip to content

Instantly share code, notes, and snippets.

@sharksforcheap
Created August 14, 2012 22:33
Show Gist options
  • Select an option

  • Save sharksforcheap/3353586 to your computer and use it in GitHub Desktop.

Select an option

Save sharksforcheap/3353586 to your computer and use it in GitHub Desktop.
a gist
def median(array)
leng=array.length
case leng
when leng%2==0
i=leng/2
med=(array[i-1].to_f + array[i].to_f) / 2
return med
else
med=array[(leng/2)]
return med
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment