Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Not in Order by book1978
def not_order(data: list[int]) -> int:
return sum(x != y for x, y in zip(data, sorted(data)))
print("Example:")
print(not_order([1, 1, 4, 2, 1, 3]))
assert not_order([1, 1, 4, 2, 1, 3]) == 3
assert not_order([]) == 0
assert not_order([1, 1, 1, 1, 1]) == 0
assert not_order([1, 2, 3, 4, 5]) == 0
print("The mission is done! Click 'Check Solution' to earn rewards!")
Nov. 10, 2022
Comments: