Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
with a dict solution in Uncategorized category for Nearest Value by lxf42
def nearest_value(values: set, one: int) -> int:
dists = {x:abs(x - one) for x in values}
return min([y for y in dists if dists[y] == min(dists.values())])
March 3, 2022