Skip to content
DeepForgeby svx
All problems
EasyLinear Algebrala-200

Tournament Score Vector

Problem

In a tournament matrix A[i][j] = 1 means player i beat player j; otherwise it is 0.

Return the score vector: the number of wins (row sums) for each player.

Hint

A valid tournament matrix has zeros on the diagonal and A[i][j] + A[j][i] = 1 off it.

Test cases

case 1
in: [[[0,1,1],[0,0,1],[0,0,0]]]
expected: [2,1,0]
case 2
in: [[[0,1],[0,0]]]
expected: [1,0]
case 3
in: [[[0,0,0],[0,0,0],[0,0,0]]]
expected: [0,0,0]
case 4
in: [[[0,1,0],[0,0,1],[1,0,0]]]
expected: [1,1,1]
Starter codePython
def tournament_scores(A):
    # Your code here
    pass

4 test cases · run your code against them in the editor