Seven-sided dice from five-sided dice: Difference between revisions
Seven-sided dice from five-sided dice (view source)
Revision as of 01:38, 6 December 2011
, 12 years ago→{{header|Go}}: library changes
m (→{{header|Go}}: library changes) |
|||
Line 525:
"fmt"
"math"
"math/rand"
"time"
)
Line 554 ⟶ 555:
// parameter "delta."
func distCheck(f func() int, n int,
repeats int, delta float64) (max float64, flatEnough bool) {
count := make([]int, n)
for i := 0; i < repeats; i++ {
Line 561 ⟶ 562:
expected := float64(repeats) / float64(n)
for _, c := range count {
max = math.
}
return max, max < delta
Line 567 ⟶ 568:
// Driver, produces output satisfying both tasks.
func main() {
rand.Seed(time.Now().UnixNano())
const calls = 1000000
max, flatEnough := distCheck(dice7, 7, calls, 500)
Line 581 ⟶ 578:
Output:
<pre>
Max delta:
Max delta:
</pre>
|