All problems
Spearman Footrule
Problem
Return the Spearman footrule distance sum(abs(rank_a_i - rank_b_i)) between two rank vectors. Return 0.0 for empty input or mismatched lengths.
Hint
It is the L1 distance between rankings.
Test cases
case 1
in: [[1,2,3],[1,2,3]]
expected: 0
case 2
in: [[1,2,3],[3,2,1]]
expected: 4
case 3
in: [[1,2,3,4],[2,1,4,3]]
expected: 4
case 4
in: [[1],[2]]
expected: 1
case 5
in: [[],[]]
expected: 0
Starter codePython
def spearman_footrule(rank_a, rank_b):
# Your code here
pass5 test cases · run your code against them in the editor