I recently interviewed with Microsoft and they asked me the following puzzle, for which I had to write an algorithm and accompanying test cases. I wasn’t able to crack it and it still is a puzzle to me.
Problem Statement :
A champagne pyramid is a pyramid made of champagne glasses , each of equal capacity say , n.
The pyramid begins with one glass at the top level , two glasses at the second level , then three below that and so on up to infinite levels. A level x of the pyramid thus has x no. of champagne glasses.
A steady stream of champagne is poured down from the top level,which trickles down to the lower levels. What is the distribution of champagne in the glasses at a given level i.
The problem is quite abstract and those are all the inputs I was given.
The answer is Normal Distribution I believe.
Have a look at the diagram:
Let’s say you have a flow of X
1 will flow into 2,3 uniformly, thus each gets 1/2X
each will flow uniformly to the glasses below it, so 4 gets 1/4X, 6 gets 1/4X and 5 gets 2*1/4X= 1/2X
At next level – the same principle applies:
At infinity – it should converge into normal distribution.
At any finite number
i– it should bef(i,n)/ 2^(i-1)wheref(i,n)is thenth binomial number for levelipolynomial. As @veredmarald indicated in comments, that distribution function is actually Binomial Distribution for p = 1/2, thus giving youflow(i)~Bin(i-1,1/2)