fork download
  1. a = [3, 6, 9, 5, 4, 8, 2]
  2. b = sorted([[e,i] for i,e in enumerate(a)])
  3. print(b)
  4. print(max([abs(n-o[1]) if 0<o[1]<len(a)-1 else 0 for n,o in enumerate(b)]))
Success #stdin #stdout 0.02s 9284KB
stdin
Standard input is empty
stdout
[[2, 6], [3, 0], [4, 4], [5, 3], [6, 1], [8, 5], [9, 2]]
4