Skip to content

Instantly share code, notes, and snippets.

@ruescasd
Created October 30, 2012 19:55
Show Gist options
  • Save ruescasd/3982601 to your computer and use it in GitHub Desktop.
Save ruescasd/3982601 to your computer and use it in GitHub Desktop.
HHH, HHT
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