티스토리 뷰

Codesignal

code signal - 19. areEquallyStrong

터보건 2020. 2. 19. 16:43

Question

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

Input/Output

  • [execution time limit] 4 seconds (py3)

  • [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.

MY_ANSWER

def areEquallyStrong(yourLeft, yourRight, friendsLeft, friendsRight):
    return {yourLeft, yourRight} == {friendsLeft, friendsRight}
  • 당신의 양 팔 중에서 가장 강한 팔과 친구의 양 팔 중에서 가장 강한 팔의 세기, 그리고 가장 강한 팔이 아닌 나머지 팔들을 서로 비교하였을 때 팔의 세기가 같아야 한다.
  • set형태를 이용하여 간단히 풀 수 있다.

Best_ANSWER

def areEquallyStrong(yourLeft, yourRight, friendsLeft, friendsRight):
    return {yourLeft, yourRight} == {friendsLeft, friendsRight}
  • Best_ANSWER도 나의 답과 동일하다.

 

'Codesignal' 카테고리의 다른 글

code signal - 21. isIPv4Address  (0) 2020.02.19
code signal - 20. arrayMaximalAdjacentDifference  (0) 2020.02.19
code signal - 18. palindromeRearranging  (0) 2020.02.19
code signal - 17. arrayChange  (0) 2020.02.19
code signal - 16. Are similar?  (0) 2020.02.16
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함