Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. f = open("testtour.txt", 'r')
  2. starttour = []
  3. i = 0;
  4. for line in f:
  5.     starttour.append(line.strip().split(' '))
  6.     i = i+1
  7. f.close()
  8.  
  9. def twoopt(tour,i,j):
  10.     tourCopy = tour
  11.     tourCopy[i+1:j+1]= reversed(tourCopy[i+1:j+1])
  12.  
  13.     return tourCopy
  14.  
  15.  
  16. print(twoopt(starttour, 0, 5))
  17. print(starttour)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement