Number of ways to place $K$ objects in $N^3$ cube On how many ways I can place $K$ objects in $N \times N \times N$ cube, assuming that in every coordinate $x$, $y$, $z$ (i.e. in every "row") may be at most one object? For example, if $N = 2$ and $K = 2$ then answer is $8$, because first object can be placed in $8$ positions, but the second object can be placed only in $1$ position.
 A: When you put an object, all positions with coordinates $x_i$ or $y_i$ or $z_i$ are removed from the set of options. Removed these coordinates leave a cube (if join new cubes) of $(N-1)\times  (N-1)\times (N-1)$. Each object can be placed in positions as the size of the cube (resized for each object). Thus, the number of ways to place $K$ objects in a cube of $N\times N\times N$ is $\displaystyle \prod_{i=0}^{K-1}(N-i)^3$.
A: Each coordinate corresponds to an ordered triple $(x,y,z)$. Your task is to create a set of $K$ triples using the numbers $1, \dots, N$ such that no two triples have a common entry. (So it is implied that $N \geq K$.)
The first object can be placed in $N \times N \times N$ (or $N^3$) ways, since there are $N$ choices for $x$, $N$ choices for $y$, and $N$ choices for $z$.
The second object can be placed in $(N -1) \times (N -1) \times (N-1)$ (or $(N-1)^3$) ways, since there are $N-1$ choices for $x$, $N-1$ choices for $y$, and $N-1$ choices for $z$. The reason for the reduced number of choices is that we cannot repeat any of the coordinates used for the first object.
The third object can be placed in $(N -2) \times (N -2) \times (N-2)$ (or $(N-2)^3$) ways, since there are $N-2$ choices for $x$, $N-2$ choices for $y$, and $N-2$ choices for $z$. We have lost two options at each coordinate since we cannot repeat what has been used by either the first or the second object.
Continue in this way for all $K$ objects and then multiply the number of choices for each object to obtain
$$
N^3 \times (N-1)^3 \times (N-2)^3 \times \cdots \times (N-K+1)^3
$$
possibilities. This expression can be written more compactly as
$$
\prod_{i = 0}^{K-1} (N-i)^3.
$$
