Skip to content

Table Tennis Problem


You manage a recreational table tennis league . There are 10 participants, and in an effort to make the first round of matchups as exciting as possible, you develop a model that predicts the score difference for every possible pair of players. That is, you produce a 10x10 matrix where (i,j) represents your prediction for player i’s score minus player j’s score if they were to compete.

import numpy as np

generator = np.random.default_rng(0)
score_diffs = np.round(generator.uniform(low=-15, high=15, size=(10,10)), 2)
np.fill_diagonal(score_diffs, np.nan)
score_diffs[np.triu_indices(10, k=1)[::-1]] = -score_diffs[np.triu_indices(10, k=1)]

print(score_diffs)
# [[   nan  -6.91 -13.77 -14.5    9.4   12.38   3.2    6.88   1.31  13.05]
#  [  6.91    nan  10.72 -13.99   6.89  -9.73  10.9    1.24  -6.01  -2.32]
#  [ 13.77 -10.72    nan   4.42   3.46  -3.49  14.92  14.43   5.57   4.51]
#  [ 14.5   13.99  -4.42    nan   0.76  -5.69  -0.42  11.68  13.02  -4.27]
#  [ -9.4   -6.89  -3.46  -0.76    nan  11.71  -8.19   3.7  -12.48   9.98]
#  [-12.38   9.73   3.49   5.69 -11.71    nan  -1.49   8.89  -8.08 -13.44]
#  [ -3.2  -10.9  -14.92   0.42   8.19   1.49    nan  13.26  -4.05 -11.84]
#  [ -6.88  -1.24 -14.43 -11.68  -3.7   -8.89 -13.26    nan  13.47  -1.2 ]
#  [ -1.31   6.01  -5.57 -13.02  12.48   8.08   4.05 -13.47    nan   6.87]
#  [-13.05   2.32  -4.51   4.27  -9.98  13.44  11.84   1.2   -6.87    nan]]

Given this matrix, determine the “best” schedule for round one - the schedule whose matchups minimize the sum of squared point differentials.


Try with Google Colab See the solution