Created
April 27, 2012 22:42
-
-
Save thanthese/2514011 to your computer and use it in GitHub Desktop.
Pull cards until ace
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
(let [big 100000.0 | |
suit (range 1 (inc 13)) | |
deck (concat suit suit suit suit) | |
; fn: how many cards pulled before ace is reached? | |
pulled (fn [] (inc (count (take-while (partial not= 1) | |
(shuffle deck)))))] | |
; take average | |
(/ (apply + (repeatedly big pulled)) | |
big)) | |
; sample output: | |
; => 10.57806 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment