👩💻 Join our community of thousands of amazing developers!
In a recent conversation, someone shared some code from a book about technical job interviews. They wanted to know if I agreed that the code was “Pythonic.”The problem was to find the runs of increasing and decreasing values in a list, and to produce a sequence of the runs, but to reverse the decreasing runs, so that they are also increasing. This was the “Pythonic” code:import itertools def mono_runs_pythonic(seq): class Monotonic: def __init__(self): self._last = floa...