Skip to content

Instantly share code, notes, and snippets.

@andybrodie
Last active April 13, 2020 18:07
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 andybrodie/fd6af70fa1c291fefac9746cb55460ad to your computer and use it in GitHub Desktop.
Save andybrodie/fd6af70fa1c291fefac9746cb55460ad to your computer and use it in GitHub Desktop.
from random import seed
from random import randint
successes = 0
failures = 0
count = 0
print("Starting loop")
while (count<1000000):
max_length = 100
x = randint(0, max_length)
y = randint(0, max_length - x)
z = max_length - x - y
count = count + 1
if (x + y >= z and x + z >= y and z + y >= x):
successes = successes + 1
else:
failures = failures + 1
print("Successes : ", successes)
print("Failures : " , failures)
@andybrodie
Copy link
Author

Corrected calculation of z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment