Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Straightforward solution in Clear category for Min and Max by nickie
def min(*args, key=None):
f = key if key is not None else lambda x: x
f_result = None
for x in args[0] if len(args) == 1 else args:
f_x = f(x)
if f_result is None or f_x < f_result:
result, f_result = x, f_x
return result
def max(*args, key=None):
f = key if key is not None else lambda x: x
f_result = None
for x in args[0] if len(args) == 1 else args:
f_x = f(x)
if f_result is None or f_x > f_result:
result, f_result = x, f_x
return result
May 8, 2014
Comments: