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:
|1|
---
|2| |3|
--- ---
|4| |5| |6|
--- --- ---
|7| |8| |9| |10|
--- --- --- ----
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:
7 gets 1/8X
8 gets 1/8X from 4 and 1/4X from 5, totaling 3/8X,
9 gets same as 8 and 10 same as 8.
At infinity - it should converge into normal distribution.
At any finite number i - it should be f(i,n)/ 2^(i-1) where f(i,n) is the nth binomial number for level i polynomial. As @veredmarald indicated in comments, that distribution function is actually Binomial Distribution for p = 1/2, thus giving you flow(i)~Bin(i-1,1/2)
I believe the distribution is even, even though the flow of the champagne follows the binomial distribution, which at infinity approaches the Normal Distribution.
The glass size has finite volume.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With