We have 7 cars parked side-by-side and 4 of them are black. To work out the number of ways the black cars can be parked next to each other, we proceed as follows:
First, we need to use a formula for choosing r items in a row out of n (r<=n).
This is n - r + 1
Because there is the first way, eg in the case of 4
b b b b . . .
and then n - r more ways as we shift to the right by 1 place each time
So, we have n = 7 spaces and r = 4 black cars. The number of ways of getting 4 black cars in a row is
7 - 4 +1 = 4 ways
Secondly, we need to think of the number of ways the individual 4 black cars can be arranged amongst themselves given that 4 black cars are arranged in 4 particular spaces.
This is the number of permutations of the 4 black cars. This is equal to
4! = 4 x 3 x 2 x 1 = 24
There are 4 ways of placing the first car and 3 ways of placing the second, 2 ways of placing the third and then only 1 way of placing the fourth.
For each possible arrangement of 4 black cars in a row there are 24 ways of arranging the individual cars amongst themselves, so in total there are
24 * (n - r + 1) = 24 * (7 - 4 + 1) = 24 * 4 = 96 ways
Answer: there are 96 ways