use reduce() to implemement max() and min().