Advertisement
Guest User

Untitled

a guest
Mar 19th, 2017
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.44 KB | None | 0 0
  1. m := make(map[string]int)
  2.     for z := 0; z < 1e6; z++ {
  3.         r := rand.NewSource(time.Now().UnixNano())
  4.         money := 1000
  5.         pay := 1
  6.         i := 0
  7.         for money-pay > 0 && i < 1e6 {
  8.             money -= pay
  9.             won := r.Int63()%2 == 1
  10.             if won {
  11.                 money += pay*2
  12.                 pay = 1
  13.             } else {
  14.                 pay *= 2
  15.             }
  16.             i++
  17.         }
  18.         if money > 1000 {
  19.             m["won"]++
  20.         } else {
  21.             m["lost"]++
  22.         }
  23.     }
  24.     fmt.Println("won  ::", m["won"])
  25.     fmt.Println("lost ::", m["lost"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement