I think there is another way to solve this problem and it may be quicker, the main concept is to break the process into the following steps:

1. Just assign 2 different coupons to the first candy and the last one 2. for the remaining n-2 coupons, just assign them randomly to the remaining x-2 candies 3. the remaining is candies without coupons

calculate the possibility of each step and then E and Var(x)

Alumni Liaison

Correspondence Chess Grandmaster and Purdue Alumni

Prof. Dan Fleetwood