# length-k sequences with n objects

Let's say I have a sequence of numbers of length $k$ with $n$ distinct objects in that sequence. Since $k\geq n,$ I know that there will be some objects in the sequence that get repeated. I have two questions:

1) How do I calculate the total number of possible sequences in the situation above?

2) Let's say now that I know the number of repetitions, e.g. "I have a 6 digit code with 3 distinct elements. One element is present once, one is present twice, and the third has three instances." This question gets a little more tricky because now it matters which element has only one instance, which has 2, etc. How, then, do you now calculate the total number of possible sequences given this information?

My question seems to be related to composition, but I can't quite figure out how to make it all work.

For $(1)$ you have $n$ choices at each of $k$ locations, so $n^k$ choices in total. For $(2)$ you have $3$ choices for the element that is represented $3$ times, then $6 \choose 3$ ways to pick where they are, $2$ ways to choose the element that appears twice, then $3 \choose 2$ ways to choose where they go. This was easier because you didn't have the same number of any pair of characters, so don't need to worry about swapping the sets.
• The process is the same for any particular arrangement. If you understand the answer for this one, you should be able to do others. If you have $n$ groups of the same size, you have to divide by $n!$ because you can choose the groups in any order. – Ross Millikan Sep 13 '16 at 4:55