Guest User

mathfactorpaste

a guest
Mar 17th, 2012
94
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def main():
  2.     import random
  3.  
  4.     planestatus = [ [1,0], [2,0], [3,0],[4,0],[5,0]]
  5.     passengers = [1,2,3,4,5]
  6.  
  7.     crazyguypos= random.randint(0,4)
  8.  
  9.  
  10.     planestatus[crazyguypos][1] = 1
  11.     del passengers[0]
  12.     i=0
  13.    
  14.     while len(passengers) != 0:
  15.        
  16.         numtoadd = passengers[i]    
  17.         if planestatus[numtoadd-1][1] == 0:
  18.             planestatus[numtoadd-1][1] = numtoadd
  19.  
  20.  
  21.         else:
  22.            
  23.             listfreepos = []
  24.             for e in range(5):
  25.                 if planestatus[e][1] == 0:
  26.                     listfreepos.append(e)
  27.            
  28.             rannum = random.randint(0,len(listfreepos)-1)
  29.            
  30.             ranpos = listfreepos[rannum]
  31.            
  32.            
  33.             planestatus[ranpos][1] = numtoadd
  34.  
  35.         del passengers[i]
  36.        
  37.     if planestatus[4][0] == planestatus[4][1]:
  38.         return 1
  39.     return 0    
  40.        
  41. thesum = 0        
  42. for e in range(200000):
  43.     thesum=thesum + main()
  44.  
  45. print thesum/200000.
RAW Paste Data