Difference of three input integers
Python 3, 21 bytes
lambda*l:sum(l)/2in l
If two numbers add to the other, the sum of all three will be double that other number, so half the sum will be an element of the list. Python 3 is needed to avoid floor-division, unless the numbers are given like 3.0
rather than 3
.
Jelly, 5 3 bytes
Thanks to @Sp3000 for saving two bytes!
Code, uses quite the same algorithm as @xnor's great answer:
SfḤ
Explanation:
S # Sum of the argument list
Ḥ # Double the list
f # Filter, remove everything that isn't equal to the sum of the list
This gives []
as falsy, and anything else as truthy.
Try it online!
ES6, 31 bytes
(a,b,c)=>a+b==c|b+c==a|c+a==b
Add 5 bytes if you need to name the function diff
.
Edit: Saved 2 bytes thanks to @Alex L.