Consider a zero-sum game with 2 contestants. Each round, each contestant chooses, independently of each other, one of \$n \ge 2\$ different choices. Depending on the two chosen choices, one player is awarded an amount from the other player's pot. For example, the following table shows the gains (positive integers) and losses (negative integers) for Player 1 for each of \$9\$ possible choices:
$$\begin{array}{c|c|c|c} & \text{Player 1 chooses A} & \text{Player 1 chooses B} & \text{Player 1 chooses C} \\ \hline \text{Player 2 chooses A} & 1 & 2 & 2 \\ \hline \text{Player 2 chooses B} & -2 & 1 & 2 \\ \hline \text{Player 2 chooses C} & 3 & -1 & 0 \\ \end{array}$$
For example, if Player 1 chooses \$A\$ and Player 2 chooses \$C\$, Player 1 gains \$3\$ and Player 2 loses \$3\$.
However, this table is needlessly complex. We can see that, assuming both players are playing to win, some choices are always suboptimal. For example, Player 1 would never choose \$B\$. No matter what Player 2 chooses, Player 1 choosing \$C\$ will produce a result that is either better or equal to \$B\$, as each element in \$C\$ is greater than or equal to its corresponding element in \$B\$. Therefore, we can say that \$C\$ dominates \$B\$, and we can remove \$\text{Player 1 chooses B}\$ from our matrix:
$$\begin{array}{c|c|c} & \text{Player 1 chooses A} & \text{Player 1 chooses C} \\ \hline \text{Player 2 chooses A} & 1 & 2 \\ \hline \text{Player 2 chooses B} & -2 & 2 \\ \hline \text{Player 2 chooses C} & 3 & 0 \\ \end{array}$$
Additionally, we can see that Player 2 would never choose \$A\$ over \$B\$, as their payoff is always higher or equal from \$B\$ than it is from \$A\$, as each value in \$B\$ is less than or equal to it's corresponding element in \$A\$. So if Player 1 chooses \$A\$, then Player 2 either loses \$1\$ (\$A\$), gains \$2\$ (\$B\$) or loses \$3\$ (\$C\$). If Player 1 instead chooses \$C\$, then Player 2 either loses \$2\$ (\$A\$), loses \$2\$ (\$B\$) or gains \$0\$ (\$C\$). In either case, Player 2 would choose \$B\$ over \$A\$, as their result would never be worse when choosing \$B\$.
Therefore, we can say that \$B\$ dominates \$A\$, and we can remove \$\text{Player 2 chooses A}\$ from the matrix:
$$\begin{array}{c|c|c} & \text{Player 1 chooses A} & \text{Player 1 chooses C} \\ \hline \hline \text{Player 2 chooses B} & -2 & 2 \\ \hline \text{Player 2 chooses C} & 3 & 0 \\ \end{array}$$
Here however, no more choices dominate. This is our final matrix, and would be the output for this input.
You are to take a rectangular matrix \$n\times m\$, where \$n, m \ge 2\$, and output the same matrix with all dominated options removed. You may also take the matrix transposed and/or with reversed signs from the examples provided in the question.
The matrices will only contain integers between \$-9\$ and \$9\$ (inclusive). You may also take \$n\$ and/or \$m\$ as input if you wish. The matrix is not guaranteed to contain any dominated options. The matrix may be reduced to a \$1\times1\$ matrix, at which point there are no more dominated options.
You may input and output in any convenient format. If there is more than one valid output, you may output any valid one. This is code-golf so the shortest code in bytes wins.
Test cases
Done by hand, don't hesitate to point out mistakes or suggest more
Input
Output
Explanation
[[ 1 2 2]
[-2 1 2]
[ 3 -1 0]]
[[-2 2]
[ 3 0]]
Column C dominates Column B, Row B dominates Row A
[[ 2 1 3 3]
[ 0 0 -1 0]
[ 1 1 0 0]]
[[0]]
Column A dominates B, Column D dominates C, Row B dominates Rows A+C, Column B dominates Column D (or vice versa)
[[ 2 0 4 1 2]
[-1 6 0 -3 3]
[ 0 -2 1 -1 1]
[ 4 -2 1 2 3]]
[[1]]
Column E dominates Column D, Row C dominates Row D, Column E dominates Column A, Row C dominates Row A, Column E dominates Column E, Row C dominates Row B, Column E dominates Column B
[[ 7 -3 -5 -9 -8 -2]
[ 6 7 6 -1 2 0]
[-5 -8 3 -1 -8 -8]
[-8 8 1 0 9 -2]
[-3 0 -1 -4 8 1]
[-2 2 -4 3 -7 -2]
[ 4 8 1 8 -9 -9]
[-1 -6 -4 1 9 5]]
[[ 7 -3 -5 -9 -8 -2]
[-5 -8 3 -1 -8 -8]
[-8 8 1 0 9 -2]
[-3 0 -1 -4 8 1]
[-2 2 -4 3 -7 -2]
[ 4 8 1 8 -9 -9]
[-1 -6 -4 1 9 5]]
Row C dominates Row B
[[ 4 -6 2 ]
[ -2 -5 -9 ]
[ 6 -2 -2 ]
[ 8 0 7 ]
[ -9 4 2 ]]
[[ 4 -6 2]
[-2 -5 -9]
[-9 4 2]]
Row C dominates Row D, Row B dominates Row C
[[ 9 -7]
[ 2 4]]
[[ 9 -7]
[ 2 4]]
No rows or columns dominate
[[ 2 2 2]
[ 2 3 2]
[ 2 2 2]]
[[2]]
Column B dominates Columns A+C, Row A dominates Rows B+C
[[ 1 4]
[ 2 0]
[ 1 4]]
[[ 2 0] or [[ 1 4]
[ 1 4]] [ 2 0]]
Rows A and C are equal so we remove one of them. Either output is OK, but removing both rows isn't.
Note that for the 7th test case, there are many different ways to get to the final version
[[-1]]
instead of[[0]]
. So, either the order does matter, either my answer is wrong. A third option is that[[-1]]
and[[0]]
are both acceptable answers for these 2 matrices. \$\endgroup\$