Cody Bable

Generation

generate functionTue, 23 May 2023

given a set of integers and a value for which you need to find the nearest one.

def nearest(x, vals): return min(vals, key=lambda y: abs(x - y)) nearest(2, {3, 5})

Questions about programming?Chat with your personal AI assistant