Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Min and Max solution in Clear category for Min and Max by John.Hammell
def min(*args, **kwargs):
key = kwargs.get("key", lambda x: x)
if len(args) == 1:
args = list(args[0])
smallest = args[0]
for item in args:
if key(item) < key(smallest):
smallest = item
return smallest
def max(*args, **kwargs):
key = kwargs.get("key", lambda x: x)
if len(args) == 1:
args = list(args[0])
largest = args[0]
for item in args:
if key(item) > key(largest):
largest = item
return largest
Oct. 5, 2015