• Code is hacky, but technically passes all tests

 

I would like to give some feedback about ...

From: http://www.checkio.org/mission/median/solve/

HTTP_USER_AGENT:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36


>>> def checkio(data):
...     le_list = sorted(data)
...     total_list = len(le_list)
...     if total_list % 2 == 0:
...         removal = total_list / 2 - 1
...         other_removal = removal * 1
...         avg_list = le_list[removal:][:other_removal]
...         return (float(avg_list[0]) + float(avg_list[1])) / 2
...     else:
...         get_even = total_list - 1
...         removal = get_even / 2
...         other_removal = removal * -1
...         final_thing = le_list[removal:][:other_removal]
...         return final_thing[0]

It passed all the tests in my macbook terminal but failed in checkio's game :(