Skip to content

Instantly share code, notes, and snippets.

@emre
Created June 4, 2014 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emre/6b45daab9971dc9f43d9 to your computer and use it in GitHub Desktop.
Save emre/6b45daab9971dc9f43d9 to your computer and use it in GitHub Desktop.
rng - this time more loops
➜ ~ python rng.py
loop: #34, difference: 0, head:600, tail:600
loop: #37, difference: 0, head:600, tail:600
loop: #53, difference: 0, head:600, tail:600
loop: #128, difference: 0, head:600, tail:600
loop: #186, difference: 0, head:600, tail:600
loop: #200, difference: 0, head:600, tail:600
loop: #213, difference: 0, head:600, tail:600
loop: #324, difference: 0, head:600, tail:600
loop: #325, difference: 0, head:600, tail:600
loop: #358, difference: 0, head:600, tail:600
loop: #370, difference: 0, head:600, tail:600
loop: #414, difference: 0, head:600, tail:600
loop: #451, difference: 0, head:600, tail:600
loop: #473, difference: 0, head:600, tail:600
loop: #515, difference: 0, head:600, tail:600
loop: #538, difference: 0, head:600, tail:600
loop: #569, difference: 0, head:600, tail:600
loop: #597, difference: 0, head:600, tail:600
loop: #600, difference: 0, head:600, tail:600
loop: #606, difference: 0, head:600, tail:600
loop: #612, difference: 0, head:600, tail:600
loop: #629, difference: 0, head:600, tail:600
loop: #651, difference: 0, head:600, tail:600
loop: #687, difference: 0, head:600, tail:600
loop: #695, difference: 0, head:600, tail:600
loop: #711, difference: 0, head:600, tail:600
loop: #777, difference: 0, head:600, tail:600
loop: #788, difference: 0, head:600, tail:600
loop: #804, difference: 0, head:600, tail:600
loop: #864, difference: 0, head:600, tail:600
loop: #872, difference: 0, head:600, tail:600
loop: #919, difference: 0, head:600, tail:600
loop: #926, difference: 0, head:600, tail:600
loop: #1072, difference: 0, head:600, tail:600
loop: #1110, difference: 0, head:600, tail:600
loop: #1201, difference: 0, head:600, tail:600
loop: #1241, difference: 0, head:600, tail:600
loop: #1276, difference: 0, head:600, tail:600
loop: #1309, difference: 0, head:600, tail:600
loop: #1347, difference: 0, head:600, tail:600
loop: #1363, difference: 0, head:600, tail:600
loop: #1444, difference: 0, head:600, tail:600
loop: #1448, difference: 0, head:600, tail:600
loop: #1490, difference: 0, head:600, tail:600
loop: #1534, difference: 0, head:600, tail:600
loop: #1536, difference: 0, head:600, tail:600
loop: #1550, difference: 0, head:600, tail:600
loop: #1551, difference: 0, head:600, tail:600
loop: #1670, difference: 0, head:600, tail:600
loop: #1719, difference: 0, head:600, tail:600
loop: #1768, difference: 0, head:600, tail:600
loop: #1775, difference: 0, head:600, tail:600
loop: #1939, difference: 0, head:600, tail:600
loop: #1966, difference: 0, head:600, tail:600
loop: #2005, difference: 0, head:600, tail:600
loop: #2034, difference: 0, head:600, tail:600
loop: #2079, difference: 0, head:600, tail:600
loop: #2094, difference: 0, head:600, tail:600
loop: #2109, difference: 0, head:600, tail:600
loop: #2128, difference: 0, head:600, tail:600
loop: #2140, difference: 0, head:600, tail:600
loop: #2156, difference: 0, head:600, tail:600
loop: #2306, difference: 0, head:600, tail:600
loop: #2347, difference: 0, head:600, tail:600
loop: #2348, difference: 0, head:600, tail:600
loop: #2417, difference: 0, head:600, tail:600
loop: #2449, difference: 0, head:600, tail:600
loop: #2454, difference: 0, head:600, tail:600
loop: #2463, difference: 0, head:600, tail:600
loop: #2473, difference: 0, head:600, tail:600
loop: #2494, difference: 0, head:600, tail:600
loop: #2560, difference: 0, head:600, tail:600
loop: #2610, difference: 0, head:600, tail:600
loop: #2665, difference: 0, head:600, tail:600
loop: #2685, difference: 0, head:600, tail:600
loop: #2706, difference: 0, head:600, tail:600
loop: #2733, difference: 0, head:600, tail:600
loop: #2753, difference: 0, head:600, tail:600
loop: #2759, difference: 0, head:600, tail:600
loop: #2792, difference: 0, head:600, tail:600
loop: #2798, difference: 0, head:600, tail:600
loop: #2831, difference: 0, head:600, tail:600
loop: #2932, difference: 0, head:600, tail:600
loop: #2938, difference: 0, head:600, tail:600
loop: #2950, difference: 0, head:600, tail:600
loop: #2952, difference: 0, head:600, tail:600
loop: #2976, difference: 0, head:600, tail:600
loop: #3041, difference: 0, head:600, tail:600
loop: #3059, difference: 0, head:600, tail:600
loop: #3120, difference: 0, head:600, tail:600
loop: #3126, difference: 0, head:600, tail:600
loop: #3143, difference: 0, head:600, tail:600
loop: #3328, difference: 0, head:600, tail:600
loop: #3339, difference: 0, head:600, tail:600
loop: #3423, difference: 0, head:600, tail:600
loop: #3471, difference: 0, head:600, tail:600
loop: #3545, difference: 0, head:600, tail:600
loop: #3556, difference: 0, head:600, tail:600
loop: #3557, difference: 0, head:600, tail:600
loop: #3564, difference: 0, head:600, tail:600
loop: #3607, difference: 0, head:600, tail:600
loop: #3642, difference: 0, head:600, tail:600
loop: #3664, difference: 0, head:600, tail:600
loop: #3700, difference: 0, head:600, tail:600
loop: #3800, difference: 0, head:600, tail:600
loop: #3805, difference: 0, head:600, tail:600
loop: #3842, difference: 0, head:600, tail:600
loop: #3911, difference: 0, head:600, tail:600
loop: #4070, difference: 0, head:600, tail:600
loop: #4124, difference: 0, head:600, tail:600
loop: #4196, difference: 0, head:600, tail:600
loop: #4200, difference: 0, head:600, tail:600
loop: #4263, difference: 0, head:600, tail:600
loop: #4276, difference: 0, head:600, tail:600
loop: #4300, difference: 0, head:600, tail:600
loop: #4341, difference: 0, head:600, tail:600
loop: #4459, difference: 0, head:600, tail:600
loop: #4512, difference: 0, head:600, tail:600
loop: #4555, difference: 0, head:600, tail:600
loop: #4683, difference: 0, head:600, tail:600
loop: #4812, difference: 0, head:600, tail:600
loop: #4838, difference: 0, head:600, tail:600
loop: #4870, difference: 0, head:600, tail:600
loop: #4928, difference: 0, head:600, tail:600
loop: #4938, difference: 0, head:600, tail:600
loop: #4951, difference: 0, head:600, tail:600
loop: #4987, difference: 0, head:600, tail:600
total equal drops: 127
import random
sides = ["head", "tail"]
results = {
"head": 0,
"tail": 0,
}
equal_drop = 0
for i in range(5000):
for j in xrange(1, 1201):
side = random.choice(sides)
results[side] += 1
difference = abs(results["head"] - results["tail"])
if difference == 0:
equal_drop += 1
print "loop: #{}, difference: {}, head:{}, tail:{}".format(i, difference, results["head"], results["tail"])
# clear the results
results["head"], results["tail"] = 0, 0
print "total equal drops: {}".format(equal_drop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment