The origin problem is here. Now it is deleted.
Suppose I have 3 'available' copies of a
, 2 of b
, 3 of c
, and 4 of d
.
- I want to know the number of different strings with length $l$ using these characters (but no more than the available copies).
- Is there an efficient (i.e. $o(k)$) algorithm for computing the $k$-th smallest string of length $l$ in lexicographic order?
For example, The first string of length 1 is a
, the second string of length 3 is aab
, the 5th string of length 5 is aaacc
(following aaabb
, aaabc
, aaabd
, and aaacb
), etc.
What kind of algorithm or math can I use to calculate?
$k-th$
, since that denotes the difference between $k$ and the product of $t$ and $h$. To be honest, I'd typeset it as just$k$th
-- one doesn't use a hyphen in "4th", for example. $\endgroup$