programming problem 1: count inversion