Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Median by Butch
def checkio(data):
"""Returns median element from given list"""
sort_data = sorted(data)
if len(sort_data) % 2 != 0:
idx = len(sort_data) / 2
return sort_data[idx]
else:
first_elem = sort_data[len(sort_data) / 2 - 1]
second_elem = sort_data[len(sort_data) / 2]
return (first_elem + second_elem) / 2.0
June 20, 2015