Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Min and Max by UFO665
def min(*args, **kwargs):
key = kwargs.get("key", None)
if type(key) == type:
val = key(args[0])
for arg in args[1:]:
if key(arg) < val:
val = arg
return val
return sorted(args[0] if len(args) == 1 else args, key=key)[0]
def max(*args, **kwargs):
key = kwargs.get("key", None)
if type(key) == type:
val = key(args[0])
for arg in args[1:]:
if key(arg) > val:
val = arg
return val
return sorted(args[0] if len(args) == 1 else args, key=key)[-1]
Dec. 9, 2015