Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Two functions solution in Clear category for Min and Max by virzen
def min(*args, **kwargs):
if len(args) < 1:
return None
key = kwargs.get("key", lambda x: x)
arguments = list(args[0]) if len(args) == 1 else args
result = arguments[0]
for val in arguments:
if key(val) < key(result):
result = val
return result
def max(*args, **kwargs):
if len(args) < 1:
return None
key = kwargs.get("key", lambda x: x)
arguments = list(args[0]) if len(args) == 1 else args
result = arguments[0]
for val in arguments:
if key(val) > key(result):
result = val
return result
Dec. 12, 2016