Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. rawFile = open("example.txt", "r")
  2. fileCon = [lines.replace("\n","").split(" ") for lines in rawFile]
  3. rawFile.close()
  4.  
  5. V = int(fileCon[0][0])
  6. E = int(fileCon[0][1])
  7. R = int(fileCon[0][2])
  8. C = int(fileCon[0][3])
  9. X = int(fileCon[0][4])
  10.  
  11. Vs = [int(x) for x in fileCon[1]]
  12. Ess = []
  13.  
  14. start = 2
  15. for i in range(E):
  16. temp = int(fileCon[start][1])
  17. temp2 = [0 for x in range(temp)]
  18. temp3 = (int(fileCon[start][0]))
  19. for x in range(temp):
  20. start += 1
  21. temp2[int(fileCon[start][0])] = int(fileCon[start][1])
  22. Ess.append((temp3,temp2))
  23. start += 1
  24.  
  25. Rs = [[-1 for x in range(E)] for y in range(V)]
  26. ARs = []
  27. counter = 0
  28. tempA = []
  29. for k in range(start,len(fileCon)):
  30. temp4 = [int(i) for i in fileCon[k]]
  31. Rs[temp4[0]][temp4[1]] = temp4[2]
  32. tempA.append([temp4[2],Vs[counter],temp4[1],temp4[0]])
  33. counter += 1
  34.  
  35. tempA.sort()
  36. tempA.reverse()
  37.  
  38. for x in range(len(tempA)):
  39. tempA[x].reverse()
  40.  
  41.  
  42. tempC = []
  43. key = tempA[0][3]
  44. tempB = tempA[0]
  45. for y in range(1,len(tempA)):
  46. if tempA[y][3] == key:
  47. tempB.append([tempA[2],tempA[3],tempA[1],tempA[0]])
  48. print (tempB,"here")
  49. else:
  50. print (tempB,"there")
  51. tempB.sort()
  52. tempC.append(tempB)
  53. tempB = []
  54. key = tempA[y][3]
  55.  
  56. tempC.reverse()
  57. tempD = [
  58.  
  59. print (tempC)
  60.  
  61.  
  62.  
  63. print (V,E,R,C,X)
  64. print (Vs)
  65. print (Ess)
  66. print (Rs)
  67. print (tempA)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement