Finding number of different $l$-song playlists given $n$ songs

601 Views Asked by At

I came across this question on the internet and I am trying to wrap my head around how to solve it.

Mark likes to listen to music while travelling. His iPod contains $n$ songs and he wants to listen to $l$ (not necessarily different) songs during a trip. So he creates a playlist such that:

  • Every song is played at least once.
  • A song can be played again only if at least $k$ other songs have been played.

Mark wants to know how many different playlists are possible. Can you help Mark determine this number? $1\le k\le n\le l\le100$.

My Approach:

We can only choose $\dfrac{n!}{(n - k)!}$ for the first $k$ songs and after that we are free to choose from the entire sample of $n$. This leaves us with $$ \frac{n!}{(n-k)!} × n^{l-k}$$ combinations.

Is my solution right? If not what detail am I missing?