Created
October 11, 2016 11:12
-
-
Save ednasawe/6aebb50fbeb3c55a9df825ec680c2fba to your computer and use it in GitHub Desktop.
Edna Sawe
This file contains 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 number_range(list_): | |
if len(list_) == 1: | |
return [list_[0]] | |
smallest = list_[0] | |
largest = list_[0] | |
for number in list_: | |
if number > largest: | |
largest = number | |
elif number < smallest: | |
smallest = number | |
return [smallest, largest] | |
def next_number_range(list_): | |
tmp_list = list_[:] | |
range_ = number_range(tmp_list) | |
tmp_list.remove(range_[0]) | |
tmp_list.remove(range_[1]) | |
return number_range(tmp_list) | |
def arrange_asc_dsc(list_): | |
tmp_list = list_[:] | |
mid_list = len(tmp_list) / 2 | |
sorted_ = [] | |
i = 0 | |
while i < mid_list : | |
range_ = number_range(tmp_list) | |
sorted_.insert(mid_list + i, range_[1]) | |
sorted_.insert(i, range_[0]) | |
tmp_list.remove(range_[0]) | |
tmp_list.remove(range_[1]) | |
i = i + 1 | |
if len(tmp_list) == 1: | |
sorted_.insert(mid_list,tmp_list[0]) | |
else: | |
pass | |
return sorted_ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment