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 alexandrov.net
def min(*args, **kwargs):
key = kwargs.get("key", lambda x: x)
args = [*args[0]] if len(args) == 1 else [*args]
res = args[0]
for it in args:
if key(it) < key(res):
res = it
return res
def max(*args, **kwargs):
key = kwargs.get("key", lambda x: x)
args = [*args[0]] if len(args) == 1 else [*args]
res = args[0]
for it in args:
if key(it) > key(res):
res = it
return res
May 15, 2019
Comments: