728x90
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 beareEquallyStrong(yourLeft, yourRight, friendsLeft, friendsRight) = true
; - For
yourLeft = 15
,yourRight = 10
,friendsLeft = 15
, andfriendsRight = 10
, the output should beareEquallyStrong(yourLeft, yourRight, friendsLeft, friendsRight) = true
; - For
yourLeft = 15
,yourRight = 10
,friendsLeft = 15
, andfriendsRight = 9
, the output should beareEquallyStrong(yourLeft, yourRight, friendsLeft, friendsRight) = false
.
설명
나의 왼팔, 오른팔과 친구의 왼팔, 오른팔의 무게가 같아야 한다.
풀이
func areEquallyStrong(yourLeft: Int, yourRight: Int, friendsLeft: Int, friendsRight: Int) -> Bool {
return (yourLeft == friendsLeft || yourLeft == friendsRight) && (yourRight == friendsRight || yourRight == friendsLeft)
}
728x90
'알고리즘 > 코드시그널' 카테고리의 다른 글
Codesignal - arrayChange (0) | 2021.04.29 |
---|---|
Codesignal - areSimilar (0) | 2021.04.29 |
Codesignal - alternatingSums (0) | 2021.04.29 |
Codesignal - alphabeticShift (0) | 2021.04.29 |
Codesignal - almostIncreasingSequence (0) | 2021.04.29 |
댓글