Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Min and Max by Tsutomu-KKE
def min(*args, **kwargs):
f = kwargs.get("key", lambda x: x)
try:
l = args
if len(l) == 1: l = list(args[0])
except:
l = args
r = l[0]
for i in range(1, len(l)):
if f(r) > f(l[i]): r = l[i]
return r
def max(*args, **kwargs):
f = kwargs.get("key", lambda x: x)
try:
l = args
if len(l) == 1: l = list(args[0])
except:
l = args
r = l[0]
for i in range(1, len(l)):
if f(r) < f(l[i]): r = l[i]
return r
May 13, 2014
Comments: