How to build a simple Mathematical formula with matching condition

256 Views Asked by At

I'm trying to write a mathematical equation that sums a set of variables on the condition that they match variables in an original array. Example:

List A: A1 = Dog, A2 = Cat, A3 = Monkey

List B: B1 = Dog, B2= Monkey

If A1 = B1, then a value of '1' would be assigned for that combination. If A1 does not equal B1, then assign value of '0' for that combination. If A1 = B2, then a value of '1' would be assigned for that match. If A1 does not equal B2, then it would be '0,' and so on until each variable in List A is compared to List B to find matches.

In the above example, List B would result in a sum total of 2. (The formula would need to apply to any list to be compared to the original List A.)

The concept is simple. I just don't know how to write the mathematical equation for it. Can anyone please help? Thank you.