Created
October 30, 2012 19:55
-
-
Save ruescasd/3982601 to your computer and use it in GitHub Desktop.
HHH, HHT
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
def base(pattern: String) = Stream.continually(util.Random.nextInt(2)) map { case 0 => 'H'; case 1 => 'T' } indexOfSlice(pattern) | |
def hhh = base("HHH") + 3 | |
def hht = base("HHT") + 3 | |
println (Seq.fill(10000)(hhh).foldLeft(0.0)(_+_) / 10000) | |
println (Seq.fill(10000)(hht).foldLeft(0.0)(_+_) / 10000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment