# Permutations with both repeating and non-repeating elements

I'm trying to find the formula to calculate the amount of permutations for $$x$$ number of elements that can repeat, $$y$$ number of elements that cannot repeat, and $$z$$ number of spaces/slots. So far I figured out the parts for when only $$x$$ elements are included: $$x^z$$, and when all elements are included but none act as repeating: $$\frac{(x+y)!}{(x+y-z)!}$$, which are basic derivations of known combinations and permutations formulas. These added together plus the cases where repeatable and non-repeatable elements are both present, and repeatable elements are repeating at least once would be the total number of permutations, but I can't seem to narrow down the formula for that part. Any guidance would be appreciated.

New contributor
user2632413 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• Not clear what you mean ... So you have $y$ singleton elemnets & $x$ elements that appear twice ? ... and you then want to put these into $z$ slots ? – Donald Splutterwit 2 days ago
• @user2642413 let z=7, manually try small values for x and y, and look for a pattern. – user2661923 2 days ago
• y singleton elements, and x elements that can appear up to z amount of times. And yes, z slots. and I tried x=2 y=2 for z = 4 and manually took about 2hrs. – user2632413 2 days ago
• $\sum\limits_{i=0}^z i! \dbinom{z}{i} \dbinom{y}{i} x^{z-i}$ should do it (proof: split the count according to what positions the $y$ nonrepeating elements are placed in). I don't think there is a simpler form. – darij grinberg 2 days ago
• ((x+y)^z)/((x+y)/y) seems to be a simpler form. Treat all elements as repeating, and then divide by the proportion of those that include a nonrepeating acting as a repeating. – user2632413 2 days ago