Question: PROGRAMMING IN C Files to submit: card_prob.c Time it took Matthew to Complete: 20 mins All programs must compile without warnings when using the -Wall
PROGRAMMING IN C
Files to submit: card_prob.c Time it took Matthew to Complete: 20 mins All programs must compile without warnings when using the -Wall and -Werror options Submit only the files requested Do NOT submit folders or compressed files such as .zip, .rar, .tar, .targz, etc Your program must match the output exactly to receive credit. Make sure that all prompts and output match mine exactly. Easiest way to do this is to copy and paste them All input will be valid unless stated otherwise Print all real numbers to two decimal places unless otherwise stated The examples provided in the prompts do not represent all possible input you can receive. All inputs in the examples in the prompt are underlined You don't have to make anything underlined it is just there to help you differentiate between what you are supposed to print and what is being given to your program If you have questions please post them on Piazza Restrictions No global variables are allowed Your main function may only declare variables, call other functions, and assign variables values.
Introduction to question
In collectible/trading card games like Magic The Gathering and Hearth Stone it is important for some decks to draw a specific card by a certain turn. For this problem you will be calculating the probability of drawing at least one copy of a specific card by a given turn. Here's how our card game will be played 1. You will initially draw N cards from your deck. This is your starting hand 2. The next step is the mulligan. In the mulligan step you select between 0 and N cards to set aside. Let the number of cards you choose to set aside be M. You will then draw M more cards from the deck. 1. Note. You cannot redraw the cards you set aside because you set them aside and did not place them back into the deck 3. You then shuffle those cards back into the deck 4. After the initial draw and the mulligan you draw one card per turn. So now we want to calculate what are the odds that you will get at least one copy of the card you are looking for by the desired turn. Note that we are actually calculating the probability in this problem and not simulating it.
Examples 1. Enter how many total cards there are in the deck: 10 Enter how many copies of the card that you are looking for are in the deck: 2 Enter your initial hand size: 2 Enter how many cards you are mulliganing: 1 Enter what turn you want to draw the card by: 3 The probability of drawing at least one of the cards by turn 3 given you mulliganed 1 cards is 0.83 2. Enter how many total cards there are in the deck: 40 Enter how many copies of the card that you are looking for are in the deck: 3 Enter your initial hand size: 3
Enter how many cards you are mulliganing: 3 Enter what turn you want to draw the card by: 2 The probability of drawing at least one of the cards by turn 2 given you mulliganed 3 cards is 0.49
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
