Subtracting lowest number from several numbers
algorithm, java, math
Solution
This should do it:
int min = Math.min(x, y);
x -= min;
y -= min;
Problem
I have two numbers. I want the lower number to be the subtracted from both values. ``` x: 1000 y: 200 => result: x = 800 and y = 0. ``` The following is kinda ugly to me, so is there a better approach I could do this? ``` if (x <= y) { y = y - x; x = 0 } else { x = x - y; y = 0; } ```