fork download
  1. function v = f(v)
  2. v(mod(v, 2) == 1) = sort(v(mod(v, 2) == 1));
  3. v(mod(v, 2) == 0) = flip(sort(v(mod(v, 2) == 0))) / 2;
  4. end
  5. f([0 9 8 4 6 5 1 2 7 3])
Success #stdin #stdout 0.14s 45664KB
stdin
Standard input is empty
stdout
ans =

   4   1   3   2   1   3   5   0   7   9