Are Equally Strong?
Call two arms equally strong if the heaviest weights they each are able to lift are equal.
Call two people equally strong if their strongest arms are equally strong (the strongest arm can be both the right and the left), and so are their weakest arms.
Given your and your friend's arms' lifting capabilities find out if you two are equally strong.
Example
For
yourLeft = 10
,yourRight = 15
,friendsLeft = 15
, andfriendsRight = 10
, the output should beare_equally_strong(yourLeft, yourRight, friendsLeft, friendsRight) = true
For
yourLeft = 15
,yourRight = 10
,friendsLeft = 15
, andfriendsRight = 10
, the output should beare_equally_strong(yourLeft, yourRight, friendsLeft, friendsRight) = true
For
yourLeft = 15
,yourRight = 10
,friendsLeft = 15
, andfriendsRight = 9
, the output should beare_equally_strong(yourLeft, yourRight, friendsLeft, friendsRight) = false
Solution
py
def are_equally_strong(yourLeft, yourRight, friendsLeft, friendsRight):
return (yourLeft == friendsLeft or yourLeft == friendsRight) and (yourRight == friendsLeft or yourRight == friendsRight)
print(are_equally_strong(10, 15, 15, 10))
js
function areEquallyStrong(yourLeft, yourRight, friendsLeft, friendsRight) {
return yourLeft + yourRight === friendsLeft + friendsRight && (yourLeft === friendsLeft || yourLeft === friendsRight);
}
console.log(areEquallyStrong(10, 15, 15, 10));