SHARE
TWEET

euromillion_run

a guest May 24th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. combn(50, 5, simplify=FALSE) %>%  # Get all (sorted) combinations of 5 choices from 1 to 50, i.e. 5,20,21,22,45
  2.     lapply(diff) %>%  # get the differences between consecutive values, i.e. 15,1,1,13
  3.     lapply(rle) %>%  # convert into runs of values, ie (1x15), (2x1s), (1x13)
  4.     sapply(
  5.         # do any of them give a run of 2 or more 1s?
  6.         # (indicating 3 or more values with difference 1)
  7.         function(x) any(x$lengths[x$values==1] >= 2)
  8.     ) %>%
  9.     mean # get the average value, which gives us the proportion (out of 1) of values that returned TRUE
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top