-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathareEquallyStrong.R
More file actions
executable file
·58 lines (56 loc) · 2.02 KB
/
areEquallyStrong.R
File metadata and controls
executable file
·58 lines (56 loc) · 2.02 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# 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] 5 seconds (r)
#
# [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.
areEquallyStrong <- function(yourLeft, yourRight, friendsLeft, friendsRight) {
if (((yourLeft == friendsLeft) & (yourRight == friendsRight)) | ((yourLeft == friendsRight) & (yourRight == friendsLeft))) {
return(TRUE)
} else {
return(FALSE)
}
}