2 added 48 characters in body edited Jan 25 '18 at 12:28 Cohensius 1468 The wrong answer got accepted! The correct answer is 3. From Wikipedia: Kendall tau distance is also called bubble-sort distance since it is equivalent to the number of swaps that the bubble sort algorithm would take to place one list in the same order as the other list. import itertools def kendell_tau_distance(order_a, order_b): pairs = itertools.combinations(range(1, len(order_a)+1), 2) distance = 0 for x, y in pairs: a = order_a.index(x) - order_a.index(y) b = order_b.index(x) - order_b.index(y) if a * b < 0: distance += 1 return distance print kendell_tau_distance([3,1,2], [2,1,3]) 3import itertools def kendall_tau_distance(order_a, order_b): pairs = itertools.combinations(range(1, len(order_a)+1), 2) distance = 0 for x, y in pairs: a = order_a.index(x) - order_a.index(y) b = order_b.index(x) - order_b.index(y) if a * b < 0: distance += 1 return distance print kendall_tau_distance([3,1,2], [2,1,3]) 3  The wrong answer got accepted! The correct answer is 3. From Wikipedia: Kendall tau distance is also called bubble-sort distance since it is equivalent to the number of swaps that the bubble sort algorithm would take to place one list in the same order as the other list. import itertools def kendell_tau_distance(order_a, order_b): pairs = itertools.combinations(range(1, len(order_a)+1), 2) distance = 0 for x, y in pairs: a = order_a.index(x) - order_a.index(y) b = order_b.index(x) - order_b.index(y) if a * b < 0: distance += 1 return distance print kendell_tau_distance([3,1,2], [2,1,3]) 3 The wrong answer got accepted! The correct answer is 3. From Wikipedia: Kendall tau distance is also called bubble-sort distance since it is equivalent to the number of swaps that the bubble sort algorithm would take to place one list in the same order as the other list. import itertools def kendall_tau_distance(order_a, order_b): pairs = itertools.combinations(range(1, len(order_a)+1), 2) distance = 0 for x, y in pairs: a = order_a.index(x) - order_a.index(y) b = order_b.index(x) - order_b.index(y) if a * b < 0: distance += 1 return distance print kendall_tau_distance([3,1,2], [2,1,3]) 3  1 answered Jan 25 '18 at 12:20 Cohensius 1468 The wrong answer got accepted! The correct answer is 3. From Wikipedia: Kendall tau distance is also called bubble-sort distance since it is equivalent to the number of swaps that the bubble sort algorithm would take to place one list in the same order as the other list. import itertools def kendell_tau_distance(order_a, order_b): pairs = itertools.combinations(range(1, len(order_a)+1), 2) distance = 0 for x, y in pairs: a = order_a.index(x) - order_a.index(y) b = order_b.index(x) - order_b.index(y) if a * b < 0: distance += 1 return distance print kendell_tau_distance([3,1,2], [2,1,3]) 3