Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- import random
- planestatus = [ [1,0], [2,0], [3,0],[4,0],[5,0]]
- passengers = [1,2,3,4,5]
- crazyguypos= random.randint(0,4)
- planestatus[crazyguypos][1] = 1
- del passengers[0]
- i=0
- while len(passengers) != 0:
- numtoadd = passengers[i]
- if planestatus[numtoadd-1][1] == 0:
- planestatus[numtoadd-1][1] = numtoadd
- else:
- listfreepos = []
- for e in range(5):
- if planestatus[e][1] == 0:
- listfreepos.append(e)
- rannum = random.randint(0,len(listfreepos)-1)
- ranpos = listfreepos[rannum]
- planestatus[ranpos][1] = numtoadd
- del passengers[i]
- if planestatus[4][0] == planestatus[4][1]:
- return 1
- return 0
- thesum = 0
- for e in range(200000):
- thesum=thesum + main()
- print thesum/200000.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement