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 CyrylWilczek
def min(*args, **kwargs):
key = kwargs.get("key", lambda x: x)
if len(args) > 1:
values = args
else:
values = list(args[0])
smallest = values[0]
for val in values:
if key(val) < key(smallest):
smallest = val
return smallest
def max(*args, **kwargs):
key = kwargs.get("key", lambda x: x)
if len(args) > 1:
values = args
else:
values = list(args[0])
highest = values[0]
for val in values[1:]:
if key(val) > key(highest):
highest = val
return highest
Jan. 13, 2018
Comments: