Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.64 KB | None | 0 0
  1. import random
  2.  
  3. def unique_check(print_origins,print_destinations,origin_check,destination_check):
  4.     count = 0
  5.     similar_destinations = []
  6.     similar_origins = []
  7.  
  8.    
  9.    
  10.  
  11.    
  12.        
  13.  
  14.    
  15.  
  16.  
  17. def create_files(Origins, Destinations, Origin_Points, Destination_Points):
  18.     origin_check = [] # makes a list containing all 50 random origin lists
  19.  
  20.     destination_check = []# makes a list containing all 50 random destination lists
  21.  
  22.     print_origins = []
  23.  
  24.     print_destinations = []
  25.  
  26.     for i in range(1,51):
  27.  
  28.         origin_list = []  # initializes a list to hold the list of origins you will generate
  29.  
  30.         destination_list = [] # initializes a list to hold the list of destinations you will generate
  31.  
  32.         num_origins = random.randint(1,len(Origin_Points)) # the random number of origins you will pull from Origin_Points
  33.  
  34.         print_origins += [num_origins]
  35.  
  36.         for i in range(num_origins):
  37.  
  38.             rand = random.randint(0,(len(Origin_Points)-1))
  39.  
  40.             origin_list += [Origin_Points[rand]]
  41.  
  42.                      
  43.         origin_check += [origin_list]
  44.  
  45.        
  46.  
  47.  
  48.         num_dests = random.randint(1,len(Destinations))
  49.  
  50.         print_destinations += [num_dests]
  51.  
  52.         for i in range(num_dests):
  53.             rand = random.randint(0,(len(Destination_Points)-1))
  54.  
  55.             destination_list += [Destination_Points[rand]]
  56.  
  57.         destination_check+=[destination_list]
  58.  
  59.  
  60.  
  61. ##    print origin_check
  62. ##    
  63. ##    
  64. ##    for i in range(len(origin_check)):
  65. ##        print origin_check[i]
  66. ##
  67. ##    for i in range(len(destination_check)):
  68. ##        print destination_check[i]
  69.  
  70.     unique_check(print_origins,print_destinations,origin_list,destination_list)
  71.  
  72.  
  73.        
  74.        
  75.          
  76.          
  77.      
  78.        
  79.      
  80.      
  81.    
  82.  
  83. def import_file():
  84.  
  85.     open_file = raw_input("Please enter the filename: ") ##imports the file
  86.  
  87.     data = open(open_file+'.txt', 'r')
  88.  
  89.     Origins = data.readline() ##establishes the first line as the total number of origins
  90.  
  91.     Origin_Points=data.readline() ## establishes the second line as a list possible origins
  92.  
  93.     Origin_Points = Origin_Points.strip()
  94.  
  95.     Origin_Points = Origin_Points.split(' ')
  96.    
  97.     Destinations = data.readline()## establishes the third line as the total number of destinations
  98.  
  99.     Destination_Points = data.readline()## establishes the final line as a list of possible destinations
  100.  
  101.     Destination_Points = Destination_Points.strip()
  102.  
  103.     Destination_Points = Destination_Points.split(' ')
  104.    
  105.     create_files(Origins, Destinations, Origin_Points, Destination_Points)
  106.  
  107.    
  108.    
  109. import_file()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement