Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Need solution for below puzzle

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Water filling logic Puzzel:

Q : Fill 10 liter container with 3 liters.

10 liter container is empty
18 liter container is empty
29 liter container have 9 liters

we can fill the container from tap but we can't drop the water away(only drop with in containers above).
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my solution , there are a number of steps , I will describe them by the quantities in the containers:

10 | 18 | 29
---------------
0 | 0 | 0
0 | 18 | 0 <- fill the 18 liters recipient
0 | 0 | 18 <- pour the 18 liters recipient into the 29 liters recipient
0 | 18 | 18 <- fill the 18 liters recipient
0 | 11 | 29 <- pour the 18 liters recipient into the 29 liters recipient
10 | 11 | 19 <- fill the 10 liters recipient
3 | 18 | 19 <- pour the 10 liters recipient into the 18 liters one => 3 liters in the first recipient
 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the problem statement there were already 9 liters in the 29 liter container.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we can;t drop the water, can we have an elephant drink it? :p Just joking

Here's the solution that I got

10 | 18 | 29
---------------
0 | 0 | 9
10| 0 | 9 <-- add 10 to 10L
0 | 0 | 19 <-- move 10 from 10L to 29L
0 | 18 | 1 <-- move 18 fro 29L to 18L
10 | 8 | 1 --- move 10 from 18L to 10L
0 | 8 | 11 <- move 10 from 10L to 29L
8 | 0 | 11<-- move 8 from 18L to 10L
10 | 0 | 11 <-- add 2 to 10L
0 | 10 | 11 <-- move 10 from 10L to 18L.. now there is 8 empty in 18L
0 | 18 | 3 <-- move 8 from 29L to 18L
3 | 18 | 0 <-- move 3 from 29L to 10L

Done!
 
Jayesh A Lalwani
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Myke Enriq wrote:Here is my solution , there are a number of steps , I will describe them by the quantities in the containers:

10 | 18 | 29
---------------
0 | 0 | 0
0 | 18 | 0 <- fill the 18 liters recipient
0 | 0 | 18 <- pour the 18 liters recipient into the 29 liters recipient
0 | 18 | 18 <- fill the 18 liters recipient
0 | 11 | 29 <- pour the 18 liters recipient into the 29 liters recipient
10 | 11 | 19 <- fill the 10 liters recipient
3 | 18 | 19 <- pour the 10 liters recipient into the 18 liters one => 3 liters in the first recipient



How do you do this

0 | 18 | 18 <- fill the 18 liters recipient
0 | 11 | 29 <- pour the 18 liters recipient into the 29 liters recipient

It should be

0 | 18 | 18 <- fill the 18 liters recipient
0 | 7 | 29 <- pour the 18 liters recipient into the 29 liters recipient
 
Does this tiny ad smell okay to you?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic