Question 1

A bag contains 5 green and 7 red jellybeans. How many ways can 5 jellybeans be withdrawn from the bag so that the number of green ones withdrawn will be less than 2?

red_jellybeans <- 7
green_jellybeans <- 5

# when green one withdrawn is 0
case1 <- choose(red_jellybeans, green_jellybeans)

# when green one withdrawn is 1
case2 <- choose(red_jellybeans, 4) * choose(green_jellybeans, 1)

total_outcome <- case1 + case2

total_outcome
## [1] 196

Question 2

A certain congressional committee consists of 14 senators and 13 representatives. How many ways can a subcommittee of 5 be formed if at least 4 of the members must be representatives?

senators <- 14
representatives <- 13
subcommittee <- 5

# when there are at least 4 representatives
case3 <- choose(representatives, subcommittee - 1) * choose(senators, 1)

# when there are at least 5 representatives
case4 <- choose(representatives, subcommittee)

total_outcome2 <- case3 + case4

total_outcome2
## [1] 11297

Question 3

If a coin is tossed 5 times, and then a standard six-sided die is rolled 2 times, and finally a group of three cards are drawn from a standard deck of 52 cards without replacement, how many different outcomes are possible?

coin_side <- 2
num_toss <- 5
dice_side <- 6
num_roll <- 2
card_deck <- 52

coin_toss <- coin_side ^ num_toss
dice_roll <- dice_side ^ num_roll

# when a group of 3 cards are picked
card_pick <- choose(card_deck, 3)

total_outcome3 <- coin_toss * dice_roll * card_pick

total_outcome3
## [1] 25459200

Question 4

3 cards are drawn from a standard deck without replacement. What is the probability that at least one of the cards drawn is a 3? Express your answer as a fraction or a decimal number rounded to four decimal places.

suit_3 <- 4
take_3 <- 3
take_card <- 0

for (x in 1:take_3) {
  take_card[x] <- (card_deck - suit_3)/card_deck
  card_deck <- card_deck - 1
}

# calculate all the value in the take_card
card_prob <- round(1 - prod(take_card),4)

card_prob
## [1] 0.2174

Question 5

Lorenzo is picking out some movies to rent, and he is primarily interested in documentaries and mysteries. He has narrowed down his selections to 17 documentaries and 14 mysteries.

Step 1. How many different combinations of 5 movies can he rent?

documentaries <- 17
mysteries <- 14
movies_total <- documentaries + mysteries
movies_pick <- 5

# when 5 movies are picked
case5 <- choose(movies_total, movies_pick)

case5
## [1] 169911

Step 2. How many different combinations of 5 movies can he rent if he wants at least one mystery?

mysteries_pick <- 0
document_pick <- 0
result <- 0

for (x in 1:movies_pick) {
  mysteries_pick[x] <- choose(mysteries, x)
  document_pick[x] <- choose(documentaries, movies_pick - x)
  result[x] <- mysteries_pick[x] * document_pick[x]
}

movie_prob <- sum(result)

movie_prob
## [1] 163723

Question 6

In choosing what music to play at a charity fund raising event, Cory needs to have an equal number of symphonies from Brahms, Haydn, and Mendelssohn. If he is setting up a schedule of the 9 symphonies to be played, and he has 4 Brahms, 104 Haydn, and 17 Mendelssohn symphonies from which to choose, how many different schedules are possible? Express your answer in scientific notation rounding to the hundredths place.

brahms <- 4
haydn <- 104
mendelssohn <- 17

case6 <- round(choose(brahms, 3) * choose(haydn, 3) * choose(mendelssohn, 3), 3)

case6
## [1] 495322880

Question 7

An English teacher needs to pick 13 books to put on his reading list for the next school year, and he needs to plan the order in which they should be read. He has narrowed down his choices to 6 novels, 6 plays, 7 poetry books, and 5 nonfiction books.

Step 1. If he wants to include no more than 4 nonfiction books, how many different reading schedules are possible? Express your answer in scientific notation rounding to the hundredths place.

non_fiction <- 5
poetry <- 7
novels <- 6
plays <- 6
book_pick <- 13
fiction_book_total <- poetry + novels + plays  
  
other_pick <- 0
non_fiction_pick <- 0
book_result <- 0

for (x in 1:non_fiction-1) {
  non_fiction_pick[x] <- choose(non_fiction, x)
  other_pick[x] <- choose(fiction_book_total, book_pick - x)
  book_result[x] <- non_fiction_pick[x] * other_pick[x]
}

book_prob <- sum(book_result)

format(book_prob, scientific = TRUE, digits = 3)
## [1] "2.39e+06"

Step 2. If he wants to include all 6 plays, how many different reading schedules are possible? Express your answer in scientific notation rounding to the hundredths place.

book_total <- fiction_book_total + non_fiction
play_pick <- choose(plays, plays) * choose((book_total - plays), book_pick - plays)

format(play_pick, scientific = TRUE, digits = 3)
## [1] "3.18e+04"

Question 8

Zane is planting trees along his driveway, and he has 5 sycamores and 5 cypress trees to plant in one row. What is the probability that he randomly plants the trees so that all 5 sycamores are next to each other and all 5 cypress trees are next to each other? Express your answer as a fraction or a decimal number rounded to four decimal places.

tree <- 5
tree_option <- 2
tree_total <- tree * tree_option

case7 <- round(tree_option * (factorial(tree) * factorial(tree)/factorial(tree_total)), 4)

case7
## [1] 0.0079

Question 9

If you draw a queen or lower from a standard deck of cards, I will pay you $4. If not, you pay me $16. (Aces are considered the highest card in the deck.)

Step 1. Find the expected value of the proposition. Round your answer to two decimal places. Losses must be expressed as negative values.

win_pay <- 4
loss_pay <- -16
card_deck2 <- 52
loss_suit_card <- 8 # 4 for kings and 4 for aces

win_rate <- ((card_deck2 - loss_suit_card)/card_deck2) * win_pay 
loss_rate <- (loss_suit_card/card_deck2) * loss_pay

case8 <- round(win_rate + loss_rate, 2)

case8
## [1] 0.92

Step 2. If you played this game 833 times how much would you expect to win or lose? Round your answer to two decimal places. Losses must be expressed as negative values.

play_time <- 833
case9 <- round(case8 * play_time, digits = 2)

case9
## [1] 766.36