Cody Bable

Generation

generate functionTue, 23 May 2023

def nearest_value(values: set[int], one: int) -> int:

def nearest_value(values: set[int], one: int) -> int: # your code here l = list(values) l.sort() l.insert(0, -abs(l[0] - one)) l.insert(len(l), abs(l[-1] - one)) z = list(map(lambda x: abs(one - x), l)) return l[z.index(min(z))]

Questions about programming?Chat with your personal AI assistant