Skip to content

Instantly share code, notes, and snippets.

@n6g7
Created December 13, 2016 15:39
Show Gist options
  • Save n6g7/518151cc7711af3f9f6c5fe940756079 to your computer and use it in GitHub Desktop.
Save n6g7/518151cc7711af3f9f6c5fe940756079 to your computer and use it in GitHub Desktop.
Numberphile guesser
import random
n = 10000
def randomize():
return random.normalvariate(0, 100)
def guess():
a = randomize()
b = randomize()
assert a != b
# Choice artefact
k = randomize()
if a>k:
# We'll suppose A is the largest
return a > b
elif a<k:
# We'll suppose A is the smallest
return a < b
success = 0
count = 0
for i in range(n):
try:
if guess():
success += 1
count += 1
except:
continue
print "guesses : %s" % count
print "successes : %s (%s%%)" % (success, (success*100./n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment