Skip to content

Extra Number

You're given three integers, a, b and c. It is guaranteed that two of these integers are equal to each other. What is the value of the third integer?

Example

For a = 2, b = 7, and c = 2, the output should be

extra_number(a, b, c) = 7

The two equal numbers are a and c. The third number (b) equals 7, which is the answer.

Input/Output

  • [input] integer a

    Guaranteed constraints:1 ≤ a ≤ 109.

  • [input] integer b

    Guaranteed constraints:1 ≤ b ≤ 109.

  • [input] integer c

    Guaranteed constraints:1 ≤ c ≤ 109.

Solution

py
def extra_number(a, b, c):
    if a == b:
        return c
    if a == c:
        return b
    return a


print(extra_number(2, 7, 2))

my thoughts are neither my employer's nor my wife's