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?

# let's check that the total combinations of all six possibilities of number of red versus green adds up to the total combinations:

# choose(12,5) = 792 total combinations

# choose(7,5)*choose(5,0) = 21   5 red, 0 green
# choose(7,4)*choose(5,1) = 175  4 red, 1 green
# choose(7,3)*choose(5,2) = 350  3 red, 2 green
# choose(7,2)*choose(5,3) = 210  2 red, 3 green
# choose(7,1)*choose(5,4) = 35   1 red, 4 green
# choose(7,0)*choose(5,5) = 1    0 red, 5 green
# total of six possibilities = 792

# so we need to add the first two possibilities together
answer = choose(7,5) + choose(7,4)*choose(5,1)
format(answer, big.mark=",", scientific=FALSE)
## [1] "196"


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?

# four reps and one senator is 13*12*11*10/4!*14
# fives reps is 13*12*11*10*9/5!
reps4 = choose(13,4)*choose(14,1) 
reps5 = choose(13,5) 

answer = reps4+reps5
format(answer, big.mark=",", scientific=FALSE)
## [1] "11,297"


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?

# note, we're assuming order matters for the coin and die but not for the cards
coinx5 = 2^5
diex2 = 6^2
cards3woRep = 52*51*50/factorial(3) # or choose(52,3)

answer = coinx5*diex2*cards3woRep
format(answer, big.mark=",", scientific=FALSE)
## [1] "25,459,200"


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.

# this was the first way I solved it but now that I understand choose() we could also do "1-choose(48,3)/choose(52,3)" which is one minus the number of ways to pick three cards that aren't three divided by the number of ways to pick three cards, or "1-48/52*47/51*46/50" which is 1 - getnnn from the list below
get333 =  4/52 *  3/51 *  2/50
get33n =  4/52 *  3/51 * 48/50
get3n3 =  4/52 * 48/51 *  3/50
get3nn =  4/52 * 48/51 * 47/50
getn33 = 48/52 *  4/51 *  3/50
getn3n = 48/52 *  4/51 * 47/50
getnn3 = 48/52 * 47/51 *  4/50
getnnn = 48/52 * 47/51 * 46/50 # just to complete pattern; not used

answer = get333+get33n+get3n3+get3nn+getn33+getn3n+getnn3
sprintf("%0.3f%%", answer*100)
## [1] "21.738%"


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?

answer1 = 31*30*29*28*27/factorial(5) # or choose(31,5)
format(answer1, big.mark=",", scientific=FALSE)
## [1] "169,911"

Step 2.

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

# answer should be the previous answer minus combinations with no mystery, or add up the combinations of the five other possibilites with 1-5 mysteries
answer2 = answer1 - 17*16*15*14*13/factorial(5) # or choose(17,5)
format(answer2, big.mark=",", scientific=FALSE)
## [1] "163,723"


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.

# we need to know how many combinations of three from each and then how many ways you can arrange 9 symphonies
brahms = choose(4,3)
haydn = choose(104,3)
mendelssohn = choose(17,3)

answer = brahms*haydn*mendelssohn*factorial(9)
format(answer, digits=4)
## [1] "1.797e+14"


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.

# pick 13 books
# plan the order 
# 6 novels, 6 plays, 7 poetry books, and 5 nonfiction books
# he wants to include no more than 4 nonfiction books
  
# choose(6,x)*choose(6,y)*choose(7,z)*choose(5,5)
# simplifies into
# choose(19,8)*choose(5,5)
# then the answer is all choices [choose(24,13)] minus the choices where there are 5 nonfiction books [choose(19,8)] times 13! for the order

answer1 = (choose(24,13)-choose(19,8))*factorial(13)
format(answer1, scientific=TRUE, digits=3)
## [1] "1.51e+16"

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.

# choose(6,x)*choose(6,6)*choose(7,y)*choose(5,z)
# simplifies into
# choose(18,7)*choose(6,6)
# then the answer is choose(18,7) times 13! for the order

answer2 = choose(18,7)*factorial(13)
format(answer2, scientific=TRUE, digits=3)
## [1] "1.98e+14"


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.

# I first think of this as making a probability tree where the possibility of drawing a sycamore is 5/10 then 4/9 then 3/8... 2/7 and 1/6 and we multiply that by 2 for the other case where we draw a cypress tree first. I did these on paper first so that reduces to 1/126.

answer1 = 2*5/10*4/9*3/8*2/7*1/6
format(answer1,  digits=2)
## [1] "0.0079"
# Another way to think about it is with factorials:
# 5! for the possibilities of drawing five sycamore in a row
# times 5! for the possibilities of drawing five cypress in a row
# divided by 10! for the possibilities of drawing 10 trees
# multiplied by 2 for the case where you draw cypress then sycamore

answer2 = factorial(5)*factorial(5)*2/factorial(10)
format(answer2,  digits=2)
## [1] "0.0079"


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.

answer1 = 4 * 44/52 - 16 * 8/52
format(answer1, digits=2)
## [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.

answer1 = 4 * 44/52 - 16 * 8/52
answer2 = answer1 * 833
format(answer2, big.mark=",", digits=5)
## [1] "768.92"