f=@(x)[x(all(t=x<=x')) x(sum(t)==1)] f([0, 15, 2, 3, 7, 18, -2, 9, 6, -5, 3, 8, 9, -14])f(5)
Standard input is empty
f = @(x) [x(all (t = x <= x')), x(sum (t) == 1)] ans = -14 18 ans = 5 5
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!