3 """ Argmin function: Returns the pair (min_value,min_index),
4 where min_index is the index of the minimum value
6 min_value = sequence[0]
8 for i,s
in enumerate(sequence):
12 return min_value, min_index
14 def keymin(dictionary):
15 """ return the key of the dictionary that has the minimum value """
16 ks = dictionary.keys()
18 min_value = dictionary[min_key]
20 if(dictionary[k] < min_value):
21 min_value = dictionary[k]
23 return min_value, min_key
28 """ Argmax function: Returns the pair (max_value,max_index),
29 where max_index is the index of the maximum value
31 max_value = sequence[0]
33 for i,s
in enumerate(sequence):
37 return max_value, max_index
40 def keymax(dictionary):
41 """ return the key of the dictionary that has the maximum value """
42 ks = dictionary.keys()
44 min_value = dictionary[max_key]
46 if(dictionary[k] > min_value):
47 min_value = dictionary[k]
49 return min_value, max_key