Empty glasses of water are arranged in the following order:When you pour liquid into the 1st glass if it's full, then the extra liquid would be flown into the glasses 2 and 3 in equal quantities. When glass 2 is full, the extra liquid would be flown into 4 and 5 and so on.Given an N liters of liquid and maximum capacity of each glass is 1 liter, give the amount of liquid  present in any glass if you empty N liters of liquid by pouring into glass by filling out the function getWaterInBucket(int N, int X) where X is the glass number. So for example if I want have 4 liters at the beginning and I want to find the water in glass 3 the function is getWaterInBucket(4, 3)How do I solve this programmatically? I tried to find a math solution using Pascal's triangle. This did not work. I considered it to be a tree so I can add a parameter like this getWaterInBucket(BTree root, int N, int X) and then try some recursive solution for each level, but parameters are not allowed in this problem. Is there something obvious, some trick?
Champaign Fountain Puzzle
algorithms;puzzles
You just need to simulate the pouring, something likevoid pour(double glasses[10], int glass, double quantity){    glasses[glass] += quantity;    if(glasses[glass] > 1.0)    {         double extra = glasses[glass] - 1.0;         pour( glasses, left_glass(glass), extra / 2 );         pour( glasses, right_glass(glass), extra / 2 );         glasses[glass] = 1.0;    }}double getWaterInGlass(int N, int X){    double glasses[10] = {0,0,0,0,0,0};    pour(glasses, 0, X);    return glasses[N];}As it stands, this is not a tree. Because different glasses pour into the same glasses, that prevents it from being a tree.