Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second. With continue solution in Uncategorized category for Sort by Removing by vvm70
def sort_by_removing(values: list) -> list:
idx = 1
while idx < len(values):
if values[idx] < values[idx-1]:
values.pop(idx)
continue
idx += 1
return values
if __name__ == '__main__':
print("Example:")
print(sort_by_removing([3, 5, 2, 6]))
# These "asserts" are used for self-checking and not for an auto-testing
assert sort_by_removing([3, 5, 2, 6]) == [3, 5, 6]
assert sort_by_removing([7, 6, 5, 4, 3, 2, 1]) == [7]
assert sort_by_removing([3, 3, 3, 3]) == [3, 3, 3, 3]
assert sort_by_removing([5, 6, 7, 0, 7, 0, 10]) == [5, 6, 7, 7, 10]
assert sort_by_removing([1, 5, 2, 3, 4, 7, 8]) == [1, 5, 7, 8]
assert sort_by_removing([1, 7, 2, 3, 4, 5]) == [1, 7]
assert sort_by_removing([]) == []
print("Coding complete? Click 'Check' to earn cool rewards!")
def sort_by_removing(values: list) -> list:
copy = values.copy()
values *= 0
for n in copy:
try:
if n < values[-1]: continue
values.append(n)
except IndexError: values.append(n)
finally: print(values)
return values
Jan. 11, 2021