Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
1-liners: third one passed all tests solution in Clear category for Nearest Value by Stensen
#nearest_value = lambda v, w: sorted(v, key=lambda i: abs(i-w))[0]
#nearest_value = lambda v, w: min(v, key=lambda i: abs(i-w))
nearest_value = lambda v, w: min((abs(i-w), i) for i in v )[1]
Sept. 20, 2020
Comments: