# puzzle - water jar

ankur rathi

Ranch Hand

Posts: 3830

Sandip Sankeshwar

Ranch Hand

Posts: 210

Ryan Maurer

Greenhorn

Posts: 5

posted 8 years ago

- 1

Here you go. I did it in 14 steps. I don't know if it can be done in fewer.

I will label the 3 jars j1, j2 and j3.

j1 holds 19 litres

j2 holds 13 litres

j3 holds 7 litres

I am starting off by filling j1 full (19 litres) and putting the remaining litre in j2, so I have this makeup

j1 = 19

j2 = 1

j3 = 0

Step 1 Fill j3

j1 = 12

j2 = 1

j3 = 7

Step 2 put j3 in j2

j1 = 12

j2 = 8

j3 = 0

Step 3 fill j3

j1 = 5

j2 = 8

j3 = 7

Step 4 fill j2 with j3

j1 = 5

j2 = 13

j3 = 2

Step 5 put j2 into j1

j1 = 18

j2 = 0

j3 = 2

Step 6 put j3 into j2

j1 = 18

j2 = 2

j3 = 0

Step 7 fill j3

j1 = 11

j2 = 2

j3 = 7

Step 8 put j3 into j2

j1 = 11

j2 = 9

j3 = 0

Step 9 fill j3

j1 = 4

j2 = 9

j3 = 7

Step 10 fill j2 with j3

j1 = 4

j2 = 13

j3 = 3

Step 11 put j2 in j1

j1 = 17

j2 = 0

j3 = 3

Step 12 put j3 into j2

j1 = 17

j2 = 3

j3 = 0

Step 13 fill j3

j1 = 10

j2 = 3

j3 = 7

Step 14 put j3 into j2

j1 = 10

j2 = 10

j3 = 0

I will label the 3 jars j1, j2 and j3.

j1 holds 19 litres

j2 holds 13 litres

j3 holds 7 litres

I am starting off by filling j1 full (19 litres) and putting the remaining litre in j2, so I have this makeup

j1 = 19

j2 = 1

j3 = 0

Step 1 Fill j3

j1 = 12

j2 = 1

j3 = 7

Step 2 put j3 in j2

j1 = 12

j2 = 8

j3 = 0

Step 3 fill j3

j1 = 5

j2 = 8

j3 = 7

Step 4 fill j2 with j3

j1 = 5

j2 = 13

j3 = 2

Step 5 put j2 into j1

j1 = 18

j2 = 0

j3 = 2

Step 6 put j3 into j2

j1 = 18

j2 = 2

j3 = 0

Step 7 fill j3

j1 = 11

j2 = 2

j3 = 7

Step 8 put j3 into j2

j1 = 11

j2 = 9

j3 = 0

Step 9 fill j3

j1 = 4

j2 = 9

j3 = 7

Step 10 fill j2 with j3

j1 = 4

j2 = 13

j3 = 3

Step 11 put j2 in j1

j1 = 17

j2 = 0

j3 = 3

Step 12 put j3 into j2

j1 = 17

j2 = 3

j3 = 0

Step 13 fill j3

j1 = 10

j2 = 3

j3 = 7

Step 14 put j3 into j2

j1 = 10

j2 = 10

j3 = 0

posted 8 years ago

Ryan you rock

Everything has got its own deadline including one's EGO!

[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]

Rajaraman Sriraman

Greenhorn

Posts: 3

posted 5 years ago

Am trying to make it to 14 steps

j1 = 19

j2 = 1

j3 = 0

-------------

j1 = 12

j2 = 1

j3 = 7

----------------

put j3 in j2

j1 = 12

j2 = 8

j3 = 0

-----------

fill j3

j1 = 5

j2 = 8

j3 = 7

--------------

fill j2 with j3

j1 = 5

j2 = 13

j3 = 2

-----------------

put j2 into j1

j1 = 18

j2 = 0

j3 = 2

-----------

put j3 into j2

j1 = 18

j2 = 2

j3 = 0

--------------

fill j3

j1 = 11

j2 = 2

j3 = 7

--------------

j3 into j2

j1 = 11

j2 = 9

j3 = 0

--------------

fill j3

j1 = 4

j2 = 9

j3 = 7

--------------

fill j2 with j3

j1 = 4

j2 = 13

j3 = 3

--------------

put j2 in j1

j1 = 17

j2 = 0

j3 = 3

--------------

put j3 into j2

j1 = 17

j2 = 3

j3 = 0

--------------

fill j3

j1 = 10

j2 = 3

j3 = 7

--------------

put j3 into j2

j1 = 10

j2 = 10

j3 = 0

--------------

Rammy Rocks

Am trying to make it to 14 steps

j1 = 19

j2 = 1

j3 = 0

-------------

j1 = 12

j2 = 1

j3 = 7

----------------

put j3 in j2

j1 = 12

j2 = 8

j3 = 0

-----------

fill j3

j1 = 5

j2 = 8

j3 = 7

--------------

fill j2 with j3

j1 = 5

j2 = 13

j3 = 2

-----------------

put j2 into j1

j1 = 18

j2 = 0

j3 = 2

-----------

put j3 into j2

j1 = 18

j2 = 2

j3 = 0

--------------

fill j3

j1 = 11

j2 = 2

j3 = 7

--------------

j3 into j2

j1 = 11

j2 = 9

j3 = 0

--------------

fill j3

j1 = 4

j2 = 9

j3 = 7

--------------

fill j2 with j3

j1 = 4

j2 = 13

j3 = 3

--------------

put j2 in j1

j1 = 17

j2 = 0

j3 = 3

--------------

put j3 into j2

j1 = 17

j2 = 3

j3 = 0

--------------

fill j3

j1 = 10

j2 = 3

j3 = 7

--------------

put j3 into j2

j1 = 10

j2 = 10

j3 = 0

--------------

Rammy Rocks

Rajaraman Sriraman

Greenhorn

Posts: 3

posted 5 years ago

j1 = 12

j2 = 1

j3 = 7

Step 2 put j3 in j2

j1 = 12

j2 = 8

j3 = 0

Step 3 fill j3

j1 = 5

j2 = 8

j3 = 7

Step 4 fill j2 with j3

j1 = 5

j2 = 13

j3 = 2

Step 5 put j2 into j1

j1 = 18

j2 = 0

j3 = 2

Step 6 put j3 into j2

j1 = 18

j2 = 2

j3 = 0

Step 7 fill j3

j1 = 11

j2 = 2

j3 = 7

Step 8 put j3 into j2

j1 = 11

j2 = 9

j3 = 0

Step 9 fill j3

j1 = 4

j2 = 9

j3 = 7

Step 10 fill j2 with j3

j1 = 4

j2 = 13

j3 = 3

Step 11 put j2 in j1

j1 = 17

j2 = 0

j3 = 3

Step 12 put j3 into j2

j1 = 17

j2 = 3

j3 = 0

Step 13 fill j3

j1 = 10

j2 = 3

j3 = 7

Step 14 put j3 into j2

j1 = 10

j2 = 10

j3 = 0

j1 = 12

j2 = 1

j3 = 7

Step 2 put j3 in j2

j1 = 12

j2 = 8

j3 = 0

Step 3 fill j3

j1 = 5

j2 = 8

j3 = 7

Step 4 fill j2 with j3

j1 = 5

j2 = 13

j3 = 2

Step 5 put j2 into j1

j1 = 18

j2 = 0

j3 = 2

Step 6 put j3 into j2

j1 = 18

j2 = 2

j3 = 0

Step 7 fill j3

j1 = 11

j2 = 2

j3 = 7

Step 8 put j3 into j2

j1 = 11

j2 = 9

j3 = 0

Step 9 fill j3

j1 = 4

j2 = 9

j3 = 7

Step 10 fill j2 with j3

j1 = 4

j2 = 13

j3 = 3

Step 11 put j2 in j1

j1 = 17

j2 = 0

j3 = 3

Step 12 put j3 into j2

j1 = 17

j2 = 3

j3 = 0

Step 13 fill j3

j1 = 10

j2 = 3

j3 = 7

Step 14 put j3 into j2

j1 = 10

j2 = 10

j3 = 0

Campbell Ritchie

Sheriff

Posts: 50204

79

colin shuker

Ranch Hand

Posts: 750

Campbell Ritchie

Sheriff

Posts: 50204

79