IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Probability Puzzles in R

Visualizza il corso

Istruzioni dell'esercizio

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

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

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)
Modifica ed esegui il codice