Download the gtools package from CRAN using
RStudio or the install.packages() command if you have not done
so. Then load the gtools library.
library(gtools)
Problem 1: In an athletic club, there are 16 male members and 10 female members. How many ways can we form a committee of 7 members if the committee must contain at least 2 females?
#There are Six possible scenarios.
#scenario 1
malec1 <- nrow(combinations(n=16, r=5, repeats.allowed = FALSE))
femalec1 <- nrow(combinations(n=10, r=2, repeats.allowed = FALSE))
c1 <- malec1*femalec1
#scenario 2
malec2 <- nrow(combinations(n=16, r=4, repeats.allowed = FALSE))
femalec2 <- nrow(combinations(n=10, r=3, repeats.allowed = FALSE))
c2 <- malec2*femalec2
#scenario 3
malec3 <- nrow(combinations(n=16, r=3, repeats.allowed = FALSE))
femalec3 <- nrow(combinations(n=10, r=4, repeats.allowed = FALSE))
c3 <- malec3*femalec3
#scenario 4
malec4 <- nrow(combinations(n=16, r=2, repeats.allowed = FALSE))
femalec4<- nrow(combinations(n=10, r=5, repeats.allowed = FALSE))
c4 <- malec4*femalec4
#scenario 5
malec5 <- nrow(combinations(n=16, r=1, repeats.allowed = FALSE))
femalec5 <- nrow(combinations(n=10, r=6, repeats.allowed = FALSE))
c5 <- malec5*femalec5
#scenario 6
femalec6 <- nrow(combinations(n=10, r=7, repeats.allowed = FALSE))
c6 <- femalec6
Adding the six possible scenarios will produce the result.
answer <- c1+c2+c3+c4+c5+c6
print(answer)
## [1] 566280
Problem 2: From a group of 7 men and 6 women,
five persons are to be selected to form a committee so that at least 3
men are there on the committee. How many ways can it be done?
#There are three possible scenarios
#scenario 1
men1 <- nrow(combinations(n=7, r=3, repeats.allowed = FALSE))
women1 <- nrow(combinations(n=6, r=2, repeats.allowed = FALSE))
comm1 <- men1*women1
#scenario 2
men2<- nrow(combinations(n=7, r=4, repeats.allowed = FALSE))
women2 <- nrow(combinations(n=6, r=1, repeats.allowed = FALSE))
comm2 <- men2*women2
#scenario 3
men3<- nrow(combinations(n=7, r=5, repeats.allowed = FALSE))
comm3 <- men3
Adding the six possible scenarios will produce the result.
comm_answer <- comm1+comm2+comm3
print(comm_answer)
## [1] 756
Problem 3: How many permutations of the letters
ABCDEFGH contain the string ABC?
#ABC string is counted as 1.
string <- nrow(permutations(n=6, r=5, repeats.allowed = FALSE))
print(string)
## [1] 720
Problem 4: Suppose that there are 9 faculty
members in the IT department and 11 in the CS department. How many ways
are there to select a committee to develop a discrete mathematics course
at a school if the committee is to consist of three IT and four CS?
IT <- nrow(combinations(n=9, r=3, repeats.allowed = FALSE))
CS <- nrow(combinations(n=11, r=4, repeats.allowed = FALSE))
program_comm <- IT*CS
print(program_comm)
## [1] 27720
Problem 5: Suppose that there are eight runners
in a race. The winner receives gold medal, the second-place finisher
receives a silver medal, and the third-place finisher receives a bronze
medal. How many different ways are there to award these medals if all
possible outcomes of the race can occur and there are no ties?
#gold medalist
n1 <- 8
#silver medalist
n2 <- 7
#bronze medalist
n3 <- 6
#Use Product Rule
runners <- n1*n2*n3
print(runners)
## [1] 336