Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Min and Max by rolandp
get_items = lambda p: p[0] if len(p) == 1 else p
def min(*args, **kwargs):
key = kwargs.get("key", lambda f: f)
m, v = None, None
for it in iter(get_items(args)):
if m == None or key(it) < v:
m, v = it, key(it)
return m
def max(*args, **kwargs):
key = kwargs.get("key", lambda f: f)
m, v = None, None
for it in iter(get_items(args)):
if m == None or key(it) > v:
m, v = it, key(it)
return m
Sept. 26, 2015
Comments: