Problem


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 = 10yourRight = 15friendsLeft = 15 and friendsRight = 10, the output should be
    areEquallyStrong(yourLeft, yourRight, friendsLeft, friendsRight) = true;
  • For yourLeft = 15yourRight = 10friendsLeft = 15 and friendsRight = 10, the output should be
    areEquallyStrong(yourLeft, yourRight, friendsLeft, friendsRight) = true;
  • For yourLeft = 15yourRight = 10friendsLeft = 15 and friendsRight = 9, the output should be
    areEquallyStrong(yourLeft, yourRight, friendsLeft, friendsRight) = false.


Input/Output

  • [input] integer yourLeft

    A non-negative integer representing the heaviest weight you can lift with your left arm.

    Guaranteed constraints:
    0 ≤ yourLeft ≤ 20.

  • [input] integer yourRight

    A non-negative integer representing the heaviest weight you can lift with your right arm.

    Guaranteed constraints:
    0 ≤ yourRight ≤ 20.

  • [input] integer friendsLeft

    A non-negative integer representing the heaviest weight your friend can lift with his or her left arm.

    Guaranteed constraints:
    0 ≤ friendsLeft ≤ 20.

  • [input] integer friendsRight

    A non-negative integer representing the heaviest weight your friend can lift with his or her right arm.

    Guaranteed constraints:
    0 ≤ friendsRight ≤ 20.

  • [output] boolean

    true if you and your friend are equally strong, false otherwise.



Solution

def areEquallyStrong(yourLeft, yourRight, friendsLeft, friendsRight):

return sorted([yourLeft, yourRight]) == sorted([friendsLeft, friendsRight])


'Programming > Algorithm' 카테고리의 다른 글

[Algorithm] isIPv4Address  (0) 2018.03.02
[Algorithm] arrayMaximalAdjacentDifference  (0) 2018.03.02
[Algorithm] palindromeRearranging  (0) 2018.02.26
[Algorithm] arrayChange  (0) 2018.02.26
[Algorithm] areSimilar  (0) 2018.02.26

+ Recent posts