Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def unique_check(print_origins,print_destinations,origin_check,destination_check):
- count = 0
- similar_destinations = []
- similar_origins = []
- def create_files(Origins, Destinations, Origin_Points, Destination_Points):
- origin_check = [] # makes a list containing all 50 random origin lists
- destination_check = []# makes a list containing all 50 random destination lists
- print_origins = []
- print_destinations = []
- for i in range(1,51):
- origin_list = [] # initializes a list to hold the list of origins you will generate
- destination_list = [] # initializes a list to hold the list of destinations you will generate
- num_origins = random.randint(1,len(Origin_Points)) # the random number of origins you will pull from Origin_Points
- print_origins += [num_origins]
- for i in range(num_origins):
- rand = random.randint(0,(len(Origin_Points)-1))
- origin_list += [Origin_Points[rand]]
- origin_check += [origin_list]
- num_dests = random.randint(1,len(Destinations))
- print_destinations += [num_dests]
- for i in range(num_dests):
- rand = random.randint(0,(len(Destination_Points)-1))
- destination_list += [Destination_Points[rand]]
- destination_check+=[destination_list]
- ## print origin_check
- ##
- ##
- ## for i in range(len(origin_check)):
- ## print origin_check[i]
- ##
- ## for i in range(len(destination_check)):
- ## print destination_check[i]
- unique_check(print_origins,print_destinations,origin_list,destination_list)
- def import_file():
- open_file = raw_input("Please enter the filename: ") ##imports the file
- data = open(open_file+'.txt', 'r')
- Origins = data.readline() ##establishes the first line as the total number of origins
- Origin_Points=data.readline() ## establishes the second line as a list possible origins
- Origin_Points = Origin_Points.strip()
- Origin_Points = Origin_Points.split(' ')
- Destinations = data.readline()## establishes the third line as the total number of destinations
- Destination_Points = data.readline()## establishes the final line as a list of possible destinations
- Destination_Points = Destination_Points.strip()
- Destination_Points = Destination_Points.split(' ')
- create_files(Origins, Destinations, Origin_Points, Destination_Points)
- import_file()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement