Created
August 14, 2012 22:33
-
-
Save sharksforcheap/3353586 to your computer and use it in GitHub Desktop.
a gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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