list re-orderng headache

Gordon Airport uce at ftc.gov
Sun Aug 24 18:55:43 EDT 2003


I don't know why, but I am wearing myself out trying to get this
to work with reasonable looking code. I need to take a list of even size
(probably >= 14, but generality never hurts) and produce a code by 
looking at the items at odd indexes from the right half and the evens 
from the left. To make things worse, the left half needs to either be 
read from the center out or reversed later.

For example from [0, 1, 2, 3, 4, 5, 6, 7. 8, 9, 10, 11, 12, 13, 14, 15]
I would encode [7, 5, 3, 1] and [8, 10, 12, 14]
and [0, 1, 2, 3, 4, 5, 6. 7, 8, 9, 10, 11, 12, 13]
gives [5, 3, 1] and [8, 10, 12]

My problem has been that with every additional 2 items you swap the odd 
and even at the middle of the list, so reading out from the center by 
two only works half the time... Maybe I want to use the extended 2.3 
index slicing too much.





More information about the Python-list mailing list