For some reason, the cmd is taking 2 minutes to run a 18 line python program. I ran it again but it did not do anything. Can anyone tell me why it is taking that long?
from array import *
file = open("IntegerArray.txt" , "r")
input_array = array('i')
for line in file:
c = int(line)
input_array.append(c)
top_array = input_array[:len(input_array)//2]
bottom_array = input_array[len(input_array)//2:]
inversion = 0
max_index = len(top_array)
for i in range(0, max_index):
for j in range(i + 1, max_index):
if top_array[i] > top_array[j]:
temp = top_array[i]
top_array[i] = top_array[j]
top_array[j] = temp
inversion = inversion + 1
print "inversion = ", inversion