Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Index manipulations solution in Clear category for Reverse Every Ascending by kkkkk
def reverse_ascending(items):
"""Return sublists in reverse order as one single list.
The end of a sublist is reached when the next number is less than
the current number.
"""
new_items = []
start_idx = 0
for idx, item in enumerate(items[:-1]):
if item >= items[idx + 1]:
new_items.extend(sorted(items[start_idx:idx + 1], reverse=True))
start_idx = idx + 1
new_items.extend(sorted(items[start_idx:], reverse=True))
return new_items
Jan. 17, 2022
Comments: