I'm trying to calculate what this problem describes as well, to estimate computation time before execution of a script, which uses cartesian power. Their 'simple example' and it's solution section directly underneath covers exactly what you need to know.
I'm really not sure on how to calculate this after heaving read about this topic for a while now. While I understand that strategy 1 is faulty, I don't fully understand strategy 2 from the linked post
My parameters are: $X^n$ and the constraint $k$. $|X|$ is known and finite. I want to compute the number of all combinations in $X^n$ where no item $x$ in each combination is found $k$ or more times within each combination.
- $X^n$ with $n\in \Bbb N$, $|X|$ is known and finite
- $x\in X$
- $0 < k < n$ constraint
For my use case it doesn't make sense to just compute and filter the the cartesian power, so I'm looking for some formula which can take my parameters to give me a possibly exact number as a result. I'm not a mathematician and unsure about how to come up with a solution for this on my own. Thanks in advance!