fork(3) download
  1. import itertools
  2.  
  3. def get_two_max(arr):
  4. output = [float('-inf'), float('-inf')]
  5. for i in arr:
  6. if i > output[0]:
  7. output[0] = i
  8. elif i > output[1]:
  9. output[1] = i
  10. return output
  11.  
  12. for x in itertools.permutations((1, 2, 3)):
  13. print(x, get_two_max(x))
Success #stdin #stdout 0.1s 10088KB
stdin
Standard input is empty
stdout
(1, 2, 3) [3, -inf]
(1, 3, 2) [3, 2]
(2, 1, 3) [3, 1]
(2, 3, 1) [3, 1]
(3, 1, 2) [3, 2]
(3, 2, 1) [3, 2]