generate functionTue, 23 May 2023
given a set of integers and a value for which you need to find the nearest one.
import math def nearest_value(values: set, one: int) -> int: return min(values, key = lambda x: math.fabs(x - one))
Python
Generate More