Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Creative category for Min and Max by JingMeng
def min_max(*args, key, reversed=False):
def _traverse(iterable):
res, res_key = None, None
for i in iterable:
if res == None or (key(i).__lt__(res_key) if reversed else key(i).__gt__(key(res))):
res, res_key = i, key(i)
return res
return _traverse(args[0] if len(args) == 1 else args)
def min(*args, key=lambda x: x):
return min_max(*args, key=key, reversed=True)
def max(*args, key=lambda x: x):
return min_max(*args, key=key)
June 20, 2019
Comments: