A die is rolled three times. Find the probability that the sum of the outcomes is (a) greater than 9. (b) an odd number.

library('glue')

# Define the number of rolls and the number of sides on each die
numofrolls <- 3
sidesondie <- 6

# Generate all possible outcomes
outcomes <- expand.grid(replicate(numofrolls, 1:sidesondie, simplify = FALSE))

# Calculate the sums of each outcome
outcomes$sum <- rowSums(outcomes)

# Calculate the probability of rolling a sum greater than 9
prob_greater_than_9 <- sum(outcomes$sum > 9) / nrow(outcomes)
glue('Probability of rolling a sum greater than 9 is {prob_greater_than_9*100}% likely.')
## Probability of rolling a sum greater than 9 is 62.5% likely.
# Calculate the probability of rolling a sum that is an odd number
prob_odd_sum <- sum(outcomes$sum %% 2 != 0) / nrow(outcomes)
glue('Probability of rolling a sum that is an odd number is {prob_odd_sum*100}% likely.')
## Probability of rolling a sum that is an odd number is 50% likely.