Skip to content

Instantly share code, notes, and snippets.

@thanthese
Created April 27, 2012 22:42
Show Gist options
  • Save thanthese/2514011 to your computer and use it in GitHub Desktop.
Save thanthese/2514011 to your computer and use it in GitHub Desktop.
Pull cards until ace
(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