Finding the middle number of three random numbers using only max and min functions in JAVA

java, max, min

Solution

what about the following?

min(min(max(a,b), max(b,c)), max(a,c))

Problem

I've solved the problem, but I'm wondering if there is a faster way. Assuming a, b, c are randomly generated numbers, is there a way to find the middle number by only using Math.max and Math.min functions? ``` med = Math.max(Math.max(Math.min(a,b),Math.min(b,c)),(Math.max(Math.min(b,c),Math.min(a,c)))); ``` Thanks a lot, any response would be greatly appreciated!

Original source