The input is an array of (at least 3, maximum 20) different integers. Each integer is greater than -1000 and smaller than 1000.
Your task is to shrink the numbers by "linearly mapping" them from 0.0
to 1.0
. This means the smallest number in the array will be mapped to 0.0, the largest to 1.0.
You get the array as a parameter (inside a function) or stdin/program arguments (you can choose). Print out the result in the format double1;double2;double3;...
. The output has to have the same order as the input.
If you want, you can round the output to 2 digits after the decimal point. There must be atleast 1 digit after the decimal point.
The usage of built-in functions (functions which scale down the numbers for you, such as mathematicas Rescale
) is disallowed.
Examples:
Input Output
[5,-20,30] 0.5;0.0;1.0
[1,2,3,4,5] 0.0;0.25;0.5;0.75;1.0
[0,5,100,400] 0.0;0.01;0.25;1.0
(The last output is rounded, otherwise it would be 0.0;0.0125;0.25;1.0
)
] max /
, however, these formatting demands make it] max / ';' . '1$' '1.0' R '^0' '0.0;' R
\$\endgroup\$