Advertisement
majkm4

Untitled

Mar 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. import sys
  2. times: list = []
  3. times.append([0, 830, 937, 834, 718, 750, 1497, 1192, 835])
  4. times.append([992, 0, 1203, 432, 567, 347, 2488, 547, 432])
  5. times.append([1025, 1204, 0, 1157, 592, 1073, 2399, 1585, 1158])
  6. times.append([835, 420, 1153, 0, 517, 117, 2332, 872, 0])
  7. times.append([671, 542, 598, 495, 0, 410, 2168, 923, 495])
  8. times.append([732, 250, 1051, 95, 414, 0, 2229, 770, 96])
  9. times.append([1571, 2168, 2522, 2406, 2289, 2321, 0, 2254, 2406])
  10. times.append([1182, 304, 1556, 736, 920, 651, 2679, 0, 736])
  11. times.append([836, 421, 1154, 1, 518, 118, 2332, 873, 0])
  12. sys.setrecursionlimit(10000)
  13.  
  14.  
  15. x: int = 9
  16. stack: list = []
  17. for i in range(x):
  18.     stack.append(0);
  19. road: int = 100000000
  20. final_road: list = []
  21. for i in range(x):
  22.     final_road.append(stack[i])
  23. counter = 1
  24. def min(n: int):
  25.     global counter
  26.     global road
  27.     global x
  28.     if(counter == x):
  29.         tmp = 0
  30.         for i in range(x-1):
  31.             tmp += times[stack[i]][stack[i+1]]
  32.         if tmp < road:
  33.             road = tmp
  34.             for i in range(x):
  35.                 final_road[i] = stack[i]
  36.     else:
  37.         for i in range(x):
  38.             tmp1 = 0
  39.             for l in range(counter):
  40.                 if i != stack[l]:
  41.                     tmp1 += 1
  42.             if tmp1 == counter:
  43.                 stack[counter] = i
  44.                 counter += 1
  45.                 min(i)
  46.     counter -= 1
  47. min(0)
  48. print(final_road)
  49. print(road)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement