Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
with bubble sort solution in Clear category for Median by masero
def bubbleSort(L):
"""A basic sorting algorithm"""
for loop in range(len(L)):
for i in range(len(L)-1):
if L[i]>L[i+1]:
L[i],L[i+1]=L[i+1],L[i]
return L
def checkio(data):
n=len(data)
data = bubbleSort(data)
return data[n//2] if n%2!=0 else (data[n//2-1]+data[n//2])/2
Aug. 5, 2014