Finding a subset of triplets of digits 0-9 such that each digit occurs 40 times in each position in the triplets
You could try using integer linear programming (ILP).  Use the following variables:


We have a variable $x_{ijk}$ for each triplet $ijk$, which is 1 if triplet $ijk$ is selected to be included in your set of 400, or 0 otherwise.
We have a variable $y_{ip}$ to count the number of times that digit $i$ appears in position $p$ among the selected triplets.


Now add constraints to capture all of your requirements:


We want to select 400 triplets: $\sum_{i,j,k} x_{ijk} = 400$.
We want each digit in each position to appear 40 times: $\sum_{i,p} y_{ip} = 40$.
We want the $x$'s and $y$'s to be consistent:

$$\begin{align}
  y_{i1} &amp;= \sum_{j,k} x_{ijk}\\
  y_{j2} &amp;= \sum_{i,k} x_{ijk}\\
  y_{k3} &amp;= \sum_{i,j} x_{ijk}
  \end{align}$$


Finally, we require $0 \le x_{ijk} \le 1$ and $0 \le y_{ip} \le 1$ for all variables.

Now give the resulting system to an integer linear programming solver, and see if it can find a solution.

If it can't find a solution after a reasonable amount of time, your next step could be to find as small a subset as possible (not necessarily size 400, but hopefully not too much larger than 400).  Thus, replace $\sum_{i,p} y_{ip} = 40$ with $\sum_{i,p} y_{ip} \ge 40$, and instead of the constraint $\sum_{i,j,k} x_{ijk} = 400$, ask the ILP solver to minimize the objective function $\sum_{i,j,k} x_{ijk}$.  That will find a way to ensure each digit is presented at least as many times as desired, using as few trials as possible.