Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
statistics.median solution in Clear category for Median of Three by Olpag
from typing import Iterable
from statistics import median
def median_three(els: Iterable[int]) -> Iterable[int]:
if len(els) <= 2:
return els
return els[:2] + [median(els[i:i+3]) for i in range(len(els))][:-2]
Sept. 12, 2019