I have a list of numbers, and I'm trying to do the following in a way as efficient as possible.
For each consecutively incrementing chunk in the list I have to reverse its order.
This is my attempt so far:
l = []
l_ = []
i = 0
while i <= len(a)-1:if a[i] < a[i+1]:l_= l_ + [a[i]]else:l = l_ + [a[i]]l_ = []i = i + 1
I'd appreciate any guidance or other approaches.
So, for the following list:
a = [1,5,7,3,2,5,4,45,1,5,10,12]
I would like to obtain:
[7,5,1,3,5,2,45,4,12,10,5,1]