Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Speedy category for Not in Order by maelnor
def not_order(data: list[int]) -> int:
return sum(int(a != b) for a, b 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!")
Dec. 21, 2022