CommencerCommencer gratuitement

Two consecutive years

First, let us see how common it is for someone to cash two years in a row.

Here, we will assume just 60 entrants, with cash awarded to the top 6. Each player is represented by a number from 1 through 60.

Cet exercice fait partie du cours

Probability Puzzles in R

Afficher le cours

Instructions

  • Determine who, if anyone, cashed in both years 1 and 2.
  • Check whether at least one person cashed in both years.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

players <- c(1:60)
count <- 0

for(i in 1:10000){
  cash_year1 <- sample(players, 6)
  cash_year2 <- sample(players, 6)
  # Find those who cashed both years
  cash_both <- 
  # Check whether anyone cashed both years
  if(___){
    count <- count + 1
  }  
}

print(count/10000)
Modifier et exécuter le code