Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
7-liner: is_ascending solution in Clear category for Reverse Every Ascending by przemyslaw.daniel
def reverse_ascending(data):
result, last = [], [data[0]] if data else []
for i in data[1:]:
is_ascending = i > last[-1]
result += last[::-1]*(not is_ascending)
last = last*is_ascending+[i]
return result+last[::-1]
Dec. 8, 2018