I am doing a worst case scenario analysis where need the solution of the following problem. A matrix of $k$ rows and $n$ columns is filled with the numbers $1,2,\ldots,k$ such that the following conditions are satisfied: 1. Every column contain all the numbers form 1 to $k$ without repetition. 2. The sum $S(k,n)$ of the variance of the $k$ rows is maximized. **Questions**: 1. What is the representation of the maximum value of $S(k,n)$ in a closed form in terms of $k$ and $n$? 2. Is there an algorithm to fill the matrix such that $S(k,n)$ is maximized?