% Answer to a question in a sample final
% Minas Spetsakis, Oct. 2018

x = 5*(rand-0.5)
% ------------------------------
if x <=-1
    fres = -x-1;
elseif x<=1
    fres = 0;
else
    fres = x-1;
end;
% -----------------------------
fres
