Skip to content

Instantly share code, notes, and snippets.

@jameynakama
Created July 21, 2011 23:43
Show Gist options
  • Save jameynakama/1098516 to your computer and use it in GitHub Desktop.
Save jameynakama/1098516 to your computer and use it in GitHub Desktop.
How many lives does it take for a skydiver to die on the first leap?
from random import *
def jump():
jumps = 0
while True:
jumps += 1
if randrange(100000) is 1:
return jumps
lives = 0
while True:
lives += 1
# just a nudge that the script is still running
# ye olde snake is murderously slow...
if lives % 100 == 0:
print "Life #%d..." % lives
if jump() == 1:
print "It took %d lives to die on the first jump!" % lives
break
"""
Life #100...
Life #200...
Life #300...
Life #400...
Life #500...
Life #600...
Life #700...
Life #800...
Life #900...
Life #1000...
Life #1100...
Life #1200...
Life #1300...
Life #1400...
Life #1500...
Life #1600...
Life #1700...
Life #1800...
Life #1900...
Life #2000...
Life #2100...
Life #2200...
Life #2300...
Life #2400...
Life #2500...
Life #2600...
Life #2700...
Life #2800...
Life #2900...
Life #3000...
Life #3100...
Life #3200...
Life #3300...
Life #3400...
Life #3500...
Life #3600...
Life #3700...
Life #3800...
Life #3900...
Life #4000...
Life #4100...
Life #4200...
Life #4300...
Life #4400...
Life #4500...
Life #4600...
Life #4700...
Life #4800...
Life #4900...
Life #5000...
Life #5100...
Life #5200...
Life #5300...
Life #5400...
Life #5500...
Life #5600...
Life #5700...
Life #5800...
Life #5900...
Life #6000...
Life #6100...
Life #6200...
Life #6300...
Life #6400...
Life #6500...
Life #6600...
Life #6700...
Life #6800...
Life #6900...
Life #7000...
Life #7100...
Life #7200...
Life #7300...
Life #7400...
Life #7500...
Life #7600...
Life #7700...
Life #7800...
Life #7900...
Life #8000...
Life #8100...
Life #8200...
Life #8300...
It took 8329 lives to die on the first jump!
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment