# probability of playing music player on shuffle and listening to every song.

I have a few problems I am trying to work out but I am not totally confident in my answers:

The problem is such: Suppose you have a playlist consisting of four songs. You play your playlist in shuffle mode. In this mode, after the current song is played, the next song is chosen randomly from the other three tracks. This ensures you never hear the same song twice in a row.Let X be the number of songs you listen to until you've heard all the four different songs.

1.How many sequences of 4 songs are there where no song plays twice in a row? If we label the songs {A, B, C, D}, then examples are ABCD and ABAB but not ABBA.

For this problem I just thought the answer was (4^4) = 256 Does this make sense?

2. I have to find the value of P(X=4). to do this I used the formula n!/(n^n) because (n^n) is the possible sequences of n songs, and because the possible sequence of n songs including every song is n!.

So my answer was: P(X=4) = 24/254 = 3/32


I am trying to understand really how this problem works, and I would like some more insight as to if these answers make sense/ how I should be tackling a problem like this. How would I compute problems like these?

Any help is appreciated.

• "In this mode, after the current song is played, the next song is chosen randomly from the other four tracks. " Did you mean the other three tracks? – Sidd Singal Apr 13 '14 at 23:47
• yes sorry I will edit that – userunknown Apr 13 '14 at 23:48
• Your first answer (4^4) isn't right, it includes things like AAAA for example. – rVitale Apr 13 '14 at 23:49
• I think I sketched an answer to this (general case) a couple of weeks ago. Of course, finding is pretty hopeless. – André Nicolas Apr 13 '14 at 23:51

## 1 Answer

I think for your number 1. The first song can be 4 different songs, right? Now how about the second song. The second song can be exactly 3 other songs, because you can't choose the same song twice. Same with the 3rd and fourth songs. That gives you 4*3*3*3 different possible choices (which equals like 108 I think).

For number 2, you did the right thing, but just replace the number from number 1.

• Thank you. For part 2, you say replace the number for part 1? Should it be 4!/108? Or does that formula that I have work? – userunknown Apr 13 '14 at 23:58
• @userunknown It should be over 108 because your question implies that it is not possible for the same song to play twice in a row, and so we can't include song sequences like AAAA in the possible total number of sequences. – Sidd Singal Apr 14 '14 at 0:00
• yes, but if I were to then calculate P(x=5) for example, that would mean I would do something like 5!/108 which is a probability larger than 1. – userunknown Apr 14 '14 at 0:02
• @userunknown This solution only works specifically for X=4 because a new song must be played EACH time. finding a solution for X=5 is much different – Sidd Singal Apr 14 '14 at 0:08