Equal Sum
EasyP3Coding
Return true if the four numbers can be split into two pairs whose sums are equal, that is, if some two of them add up to the same value as the other two. Otherwise return false.
Example 1
- Input
- a = 1, b = 2, c = 3, d = 4
- Output
- true
- Why
- 1 + 4 = 2 + 3.
Example 2
- Input
- a = 1, b = 1, c = 1, d = 1
- Output
- true
Example 3
- Input
- a = 1, b = 2, c = 3, d = 5
- Output
- false
- Why
- No split gives equal sums.
Constraints
- -10^9 <= a, b, c, d <= 10^9
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 8. ⌘Enter runs, ⌘⇧Enter submits.