
Christian H. answered 10/04/20
Aerospace Engineer and Theoretical Computer Scientist
To think about this problem, we can first make the following observation: If the next chocolate you choose is different than the last one and you end up putting this chocolate back in the bag, you can really skip worrying about this event because the next chocolate you grab, you will eat. What this implies is that we can really just pretend that every chocolate we grab, we will eat. If we view milk chocolates as a 1 bit and dark chocolates as a 0 bit, the sequence we eat chocolates in can be thought of as a binary string, e.g. 1000000001. Thus, to reason about the desired probability, we can count the proportion of 10 bit binary strings with exactly two 1 bits such that the last bit is equal to 1.
Define B(n,k) as the binomial coefficient that represents "n choose k", namely the number of size k sets you can get from a set of n elements. The total number of 10 bit binary strings with exactly two 1 bits is equal to the number of size 2 subsets you get from a set of 10 numbers, so B(10, 2) = 10!/(2! 8!) = 45. To count the number of 10 bit strings with exactly two 1 bits and where the last bit is a 1, we can fix the last bit as a 1 and then count the number of 9 bit binary strings we can form that have exactly one 1 bit, namely B(9,1) = 9.
The above results give us our desired probability as 9 / 45 = 1 / 5.