Created
March 11, 2022 20:06
-
-
Save rexarski/5339d53cc42f8a3a5ea360867af27dfc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
set.seed(1234234) | |
my_selection <- c(6, 7, 8, 9) | |
dat0 <- expand_grid(a = 1:6, b = 1:6, c = 1:6, d = 1:6) | |
dat0 <- dat0 |> | |
mutate( | |
sum12 = a + b, | |
sum13 = a + c, | |
sum14 = a + d, | |
sum23 = b + c, | |
sum24 = b + d, | |
sum34 = c + d, | |
win = if_else(sum12 %in% my_selection | | |
sum13 %in% my_selection | | |
sum14 %in% my_selection | | |
sum23 %in% my_selection | | |
sum24 %in% my_selection | | |
sum34 %in% my_selection, | |
TRUE, FALSE | |
) | |
) | |
paste0( | |
"There are ", | |
sum(dat0$win), | |
" winning cases out of all 1296 possible combinations. ", | |
"The winning rate is: ", mean(dat0$win) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment