---
title: "R Problem due Tuesday 9/25"
author: "YOUR NAME"
output: pdf_document
---

Acknowledgements: ADD NAMES HERE IF ANYONE ASSISTED YOU.  

**Email knitted pdf file to tleise@amherst.edu by 4pm on the due date.**

## Read Problem 2.30. Then answer the problem by completing the parts below. The question has been modified from the book problem to assist you with learning more about R functions and simulations.

a. In your own words, describe what needs to change to use the Monty Hall problem code to solve this problem.

> ANSWER


b. The unmodified Monty Hall problem code is below. FOUR lines need a change in order for the code to be appropriate to address problem 2.30.  Identify these lines and make the appropriate changes. Adjust the top comment with your name, and add a comment at EACH of your changes to keep track of what you did. For example, if you change the line "win<-0" to "win<-1" (for some reason), add a comment so that the line might read: "win<-1 #up from 0". You can make other changes - like changing the function name, but that is not strictly necessary. 

```{r}
#### Modified Monty Hall Problem Code
#### Based on Code by Corey Chivers, 2012
#### Modified by YOUR NAME, DATE

monty<-function(strat='stay',N=1000,print_games=FALSE) 
{   doors<-1:3 
    win<-0 
for(i in 1:N) { 
 prize<-sample(1:3, 1) 
 guess<-sample(1:3, 1) 
 if(prize!=guess)
   reveal<-doors[-c(prize, guess)]
 else
   reveal<-sample(doors[-c(prize, guess)], 1) 
 if(strat=='switch')
   select<-doors[-c(reveal, guess)]
 if(strat=='stay')
   select<-guess
 if(select==prize){
   win<-win+1
   outcome<-'Winner!'
 }else
 outcome<-'Loser!'
if(print_games)
 cat(paste('Guess: ', guess,
 '\nSelection: ', select,
 '\nPrize door: ', prize,
 '\n', outcome, '\n\n', sep=''))   }
 cat(paste('Using the ',strat,' strategy, your win percentage was ',win/N*100,'%\n',sep=''))  }
```

c. Now, use the code to answer the problem posed in Ask Marilyn: "What should you do?" Write a well-constructed paragraph conveying your response to "What should you do?". Be sure to reference your simulation results! Remember you need to set a seed to obtain reproducible results. 

> ANSWER

```{r}

```

*Acknowledgement: Thank you to Prof Amy Wagaman for sharing this R problem for STAT 360.*
