Basically, if I have a function like this:
function foo (int a, int b, int c) { return true if two out of the three variables are true otherwise false }
Is there a simple and concise way to find out if n numbers from a set are equal? How about only three items? Is there a mathematical operation that I can use? I know that I can take an iterative approach to the solution, I'm just wondering if there are other solutions that are clearer.
Here is the breakdown of the conditions because it is difficult for me to express the problem:
if no numbers are equal, return false if two numbers out of three are equal, return true if all three numbers are equal, return false
Elijah
source share