Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m := make(map[string]int)
- for z := 0; z < 1e6; z++ {
- r := rand.NewSource(time.Now().UnixNano())
- money := 1000
- pay := 1
- i := 0
- for money-pay > 0 && i < 1e6 {
- money -= pay
- won := r.Int63()%2 == 1
- if won {
- money += pay*2
- pay = 1
- } else {
- pay *= 2
- }
- i++
- }
- if money > 1000 {
- m["won"]++
- } else {
- m["lost"]++
- }
- }
- fmt.Println("won ::", m["won"])
- fmt.Println("lost ::", m["lost"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement