Challenge - "Highscore" output equation

59 Views Asked by At

I need an equation capable of processing 2 inputs to make one output that is either = to input 1 or 2. This is how it works.

Since it is working with scores and such, Input1 will be "Last Score", and Input2 will be "Current High Score". This equation I need has to compare the two, and whichever is higher, output that number.

I don't know if this is possible, just thought of this as an interesting challenge.

HARDER CHALLENGE
Do it only with +,-,/,x

1

There are 1 best solutions below

1
On

One possible way to do this that has simple computation is using the $\operatorname{sign}$ function to discriminate whereas $x-y$ is negative or positive, and add/substract accordingly:

$$f(x,y)=\frac{1}{2}\Bigl(x+y+x\operatorname{sign}(x-y)+y\operatorname{sign}(y-x)\Bigr)$$