Showing posts with label Puzzle. Show all posts
Showing posts with label Puzzle. Show all posts

River, Temple and Flowers Puzzle

Puzzle -
There are 3 temples and 3 rivers. The river and the temple are alternatively.
Like -  River Temple River Temple River Temple
A man with some flowers; while crossing river, flowers gets doubled and he puts equal number of flowers in each temple. At the end no flower is left with him.

How many flowers initially person carried ?
How many flowers he put in each temple ?


Solution –

River
Temple
River
Temple
River
Temple
Flowers put in Temple

X

X

X
 Start (P)
R1
T1
R1
T2
R3
T3

Let’s assume flowers put in each temple are X

Now just think about one temple at time.
First start with temple T3; assume man have A number of flowers at start point. He have to cross 3 rivers R1,R2,R3 to reach in temple T3. So Flowers get doubled 3 times,  Hence Total number of flowers after reaching temple T3 are 2 x 2 x 2 x A = 8A

Form and
Also 8A = X and A = X/8  

Now also assume B number of Flowers for temple T2, and 2 times need to cross rivers ( R1 & R2). Hence Total number of flowers after reaching temple T3 are 2  x 2 x  B = 4B

Form and
Also 4B = X and B = X/4

Same for temple T1, assume C number of flowers required and one river need to cross.
So 2 x C = X and C= X/2  

Form ①, ③, ⑤ and
Total number of flowers required = A + B + C = X/8 + X/4 + X/2
Multiply 8 by both sides
8 x (A + B + C ) = X + 2X + 4 X = 7X

A + B + C = 7X / 8
Start putting X value form 1, 2, 3, 4, 5, 6, 7, 8, …
Only X = 8 value gives perfect integer value ( Flowers count is always Integer).
And  A + B + C = 7  

Number of flowers initially person carried  = 7
Number of flowers he puts in each temple  = 8
========================================================================
Above solution will give answer for 3 rivers and 3 temples, and flowers are increased by double while moving into river.
Now find common formula which will give answer for k number of rivers and k number of temples and flowers are increased by m times while moving into river.

Form ①, ③, ⑤ and
Total number of flowers = X/2 + X/4+ X/8 = (X + X/2 + X/4 + X/8) –X
X+ X/21 + X/22 + X/23–X      
So here k = 3 and m = 2
Sum of Geometric progression formula
a + ar + ar2  + ... + ar(n-1)  =
,  r≠1 
From ⑦  and

Let a = X, n-1 = 3 = k and r = ½ = 1/m

Total number of flowers =
Solve equation by putting available values of k and m, it will give answer in term of  x/y   (Rational Number) then x = Total number of flowers and y = Number of flowers he puts in each temple.

Let verify for 4 temples and 4 rivers, and flowers get triple after crossing river.
k = 4 and m = 3solve this equation, will get answer 40/81
Total number of flowers= 40
Number of flowers he puts in each temple = 81

========================================================================

In some cases river count is less by 1 as compare to temple, means first temple will come and then River. Like - Temple River Temple River Temple.
In that case formula become
where k= Number of temple and m times flower increased in river

Verify for 3 temples, 2 rivers and 2 times flowers increased in river
Answer in terms of x/y=7/4 is 
Total number of flowers= 7
Number of flowers he puts in each temple =

I tried to solve this puzzle in terms of mathematical equation with all scenarios. 

Please share your valuable feedback in comment section and if any correction please update in comment. 

Camel and 3000 Bananas Puzzle

I want to share one puzzle which was asked to me in one technical interview. 

Puzzle- One camel owner want to transport 3000 Bananas to market, which is 1000 Km from his house. Maximum 1000 Bananas camel can carry one time. It (camel) eats one banana for every Km it travels.

What is the largest number of bananas that can be delivered to the market ?

Solution -

Let distance between A and B is 1000 Kms.
First find distance, where camel can carry 2000 bananas(Multiple of max. carrying capacity) i.e. Point C .
So 3 times camel need to travel Distance AC, also 2 times need to comeback from C to A.

Total distance traveled between AC = 3 x Distance AC + 2 x Distance CA = 3X+2X = 5X                                                                                                                                                               

Also 1 Km = 1 bananas. So 1000 bananas completed = 1000km traveled  

From  and 
                      1000 Kms = 5X means X= 200 Kms.                                                                                          
Now Same steps for Distance CD. 2 times camel need to travel Distance CD, also once need to comeback from D to C.

Total Distance traveled between CD =  2 x Distance CD + 1 x Distance DC  = 2Y+Y= 3Y   

From  and 
                       1000 Kms = 3Y means Y= 1000/3 = 333 Kms                                                    

Here 1000 not divisible by 3, So distance traveled 333 x 3 =999 Kms between CD.

So total Bananas remaining 2000 -999 = 1001 bananas                                                  

Now total distance between AD = Distance AC + Distance CD = X + Y = 200 +333 = 533.
Remaining distance = 1000 -533 = 467 Kms

Max. carrying capacity 1000 bananas and  467 bananas for remaining  467 Kms. So Bananas delivered to at  Point B is 1000 – 467= 533 bananas                                                             

Maximum possible bananas delivered to market are 533.