determine_winner: Determine if the contestant has won.

Description Usage Arguments Details Value Examples

View source: R/monty-hall-problem.R

Description

determine_winner() returns the "WIN" or "LOSE" game result.

Usage

1
determine_winner(final.pick, game)

Arguments

final.pick

Numeric vectors, length 1, between 1 and 3.

game

character vector, length 3, any combination of one "car" and two "goat".

Details

If the contestant's final selection contains the car, they win. The function will return "WIN"; otherwise they lost/ if a goat behind their final door selection. The function will return "LOSE" for this scenario.

Value

The function returns a length 1 character vector indicating the game result.

Examples

1
2
3
4
5
6
7
8
9
  determine_winner( 1, c("goat","goat","car") )
  determine_winner( 2, c("goat","goat","car") )
  determine_winner( 3, c("goat","goat","car") )
  determine_winner( 1, c("car","goat","goat") )
  determine_winner( 2, c("car","goat","goat") )
  determine_winner( 3, c("car","goat","goat") )
  determine_winner( 1, c("goat","car","goat") )
  determine_winner( 2, c("goat","car","goat") )
  determine_winner( 3, c("goat","car","goat") )

lghb2005/montyhall documentation built on Jan. 30, 2021, 12:46 a.m.