from sys import argv, exit # provided # # Read integers from the given filename. # # Return value: list of integers def read_array(filename): try: with open(filename) as f: return [int(n) for n in f.read().split()] except: exit("Couldn’t read numbers from file \""+filename+"\"") # implement # # Return the number of inversions in the given list, by doing a merge # sort and counting the inversions. # # Return value: number of inversions def count_inversions(in_list): return 0 # implement # # Merge the left & right lists into in_list. in_list already contains # values--replace those with the merged values. # # Return value: inversion count def merge_i(l_list, r_list, in_list): return 0 # provided if __name__ == '__main__': if len(argv) != 2: exit("usage: python3 "+argv[0]+" datafile") in_list = read_array(argv[1]) print(count_inversions(in_list))