Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Basic solution solution in Clear category for Min and Max by u8m_
# migrated from python 2.7
def min_max(args, kwargs, compare_func):
key = kwargs.get("key", None)
if key is None:
key = lambda x: x
if len(args) == 1:
args = list(args[0])
conv_args = list(map(key, args))
result = None
for i,v in enumerate(conv_args):
if result is None or compare_func(v,result):
result = v
result_index = i
return args[result_index]
def min(*args, **kwargs):
return min_max(args, kwargs, lambda a,b: ab)
Nov. 14, 2015
Comments: