Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Changing direction by Buggerman
from itertools import pairwise, groupby
def changing_direction(elements: list[int]) -> int:
a = (y > x for x, y in pairwise(elements) if x != y)
return l if (l := len(list(groupby(a))) - 1) > 0 else 0
June 4, 2024