Condition.
In the list, all elements are different. Change places the minimum and maximum item of this list.
a = [int (i) for i in input (). Split ()]
A [A.INDEX (MAX (A)]], A [A.INDEX (MIN (A))] = A [A.INDEX (MIN (A)]], A [A.INDEX (MAX (A)) ]
Print ('' .join ([STR (I) for i in a]))
In some examples, the program works, in others it simply issues the original list. For example: on the 3 4 5 list, 1
does not work, and on the 1 5 4 3 list
works.
Answer 1, Authority 100%
a little rewrote your code, but the meaning is the same:
a = [int (i) for i in input (). Split ()]
min_index = a.index (MIN (A))
max_index = A.INDEX (MAX (A))
[a [max_index], a [min_index]] = [A [MIN_INDEX], A [MAX_INDEX]]
Print ('' .join ([STR (I) for i in a]))