0% found this document useful (0 votes)
51 views4 pages

A Review On Two Water Jugs Problem Via An Algorithmic Approach

Uploaded by

Animesh Prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views4 pages

A Review On Two Water Jugs Problem Via An Algorithmic Approach

Uploaded by

Animesh Prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

nd

2 International Conference on Current Research Trends in Engineering and Technology


© 2018 IJSRSET | Volume 4 | Issue 5 | Print ISSN: 2395-1990 | Online ISSN : 2394-4099
Themed Section: Engineering and Technology

A Review on Two Water Jugs Problem via an Algorithmic Approach


Snehal Solanki1, Prem Parmar2, Parth Shukla3, Dhruvin Patel4, Mr.Nimit Modi5, Dr.Sheshang Degadwala6
1-4
U.G, Student, Computer Engineering, Sigma Institute of Engineering, Bakrol, Vadodara, Gujarat, India
5
Assistant Professor, Computer Engineering, Sigma Institute of Engineering, Bakrol, Vadodara, Gujarat, India
6
Head of Department, Computer Engineering, Sigma Institute of Engineering, Bakrol, Vadodara, Gujarat, India

ABSTRACT
The water jugs problem is a well-known problem in recreational mathematics, problem-solving, artificial
intelligence, computer programming and cognitive psychology. The methods of solutions are usually based on
heuristics or search methods such as breadth first search (BFS) or depth first search (DFS), which could be time
and memory consuming sometimes. The existing methods of solutions are often non-algorithmic in nature. In
this paper, we present an arithmetic approach to solve this problem, which is simple and suitable for manual
calculation or programming language implementation. Analysis of the solution steps involved and some
illustrative examples are provided.
Keywords : Water jugs problem, Artificial Intelligence, Problem solving, Diophantine approach, Extended
Euclidean approach.

goal totally depends on the assumption that are made


I. INTRODUCTION over the value of X and Y.
The Artificial Intelligence is the study of how to make In this paper a simple Arithmetic approach to solve the
computers to do things better than the human being. problem that was introduced. A novel feature of this
As the term says, here the water jug problem is well- approach is that one can deduce the total amount of
known problem in Artificial Intelligence [1], water in jugs at each step by getting the value of X and Y
Computer Programming [2], Problem solving [3], by using the backward approach. When these values are
Geometry [4], Recreational and discrete Mathematics just substituted in the Extended Euclidean equation our
[5,6] and Psychology [7,8,9]. goal will be reached. Due to its simplicity it is very
You are at the side of a river. You have a 3 liter jug suitable for manual calculation of the proving steps.
and a 5 liter jug. The jugs do not have marking to The whole paper is organized as follows. In section 2
allow measuring smaller quantities. How can you use the Arithmetic approach for solving the general two
the jugs to measure 4 liters of water? water jugs problem and it describe the mathematical
There are various methods to solve this problem, background behind. In the third section, illustration
including Breadth First search [10], Depth First Search of how to use the new approach with some examples
[11] and the Diophantine approach [12]. is explained. Then in the final section some
However each and every method has its own concluding remarks are explained.
disadvantages that is in BFS the role is not get trapped II. AN ARITHMETIC APPROACH TO THE WATER
by exploring a blind alley. In DFS, by chance we can JUG PROBLEM
assure that we will be getting the goal earlier and the A simple arithmetic approach to the general two
memory space is less. In Diophantine approach the water jugs problem was introduced which is applied

CI021 | Published : 10- April -2018 | March-April - 2017 [(4) 5: 331-334]


331
to solve the problem below: Let m,n be positive (m , n). Using the algorithm 2.1 we obtain the integer
integers. You are at the side of a river. You have a m- sequence.
liter jug and a n-liter jug, where 0<m<n. The jugs do Finding out the GCD is the first process and after that
not have markings to allow measuring smaller we have to use the Back-substitution method.
quantities. How can you use the jugs to measure d(<n) Algorithm 2.2:
liters of water? 1. In each of the equations, subtract the product term
The Extended Euclidean algorithm is usually used from the number on the left-hand-side and set it equal
simply to find the greatest common divisor of two remainder on the right-hand-side. 2. Backwards:
integers. The standard Euclidean algorithm gives the Write down the _last_ flipped equation, the one with
greatest common divisor and nothing else. the gcd in it, and then alternate it by subbing the
However, if we keep track of a bit more information smallest underlined term and collecting terms the
as we go through the algorithm, we can discover how remaining terms.
to write the greatest common divisor as an integer From this algorithm, the number of subtractions and
linear combination of the two original numbers. In additions involved will provide a solution to the
other words, we can find integers s and t such that problem. By using this Extended Euclidean Approach
gcd(a, b) = sa + tb. From this equation we will be and the Backward Substitution method actual pouring
obtained only the GCD (m,n) but after getting it we sequence can be determined easily by looking at the
have to follow a new procedure Back Substitution numbers appeared in the integer sequence obtained.
Method. The conclusion of this will be m( x‟) + n (y‟) III. EXAMPLE
where x‟= number of moves to be carried out by x We are given 2 jugs, a 4 liter one and a 3- liter one.
and y‟= number of moves to be carried out by y. Neither has any measuring markers on it. There is a
As a reminder, here are the steps of the standard pump that can be used to fill the jugs with water. How
Euclidean algorithm to find the greatest common can we get exactly 2 liters of water in to the 4-liter
divisor of two positive integers a and b. Algorithm 2.1 jugs?

Input: The integers m, n and d, where 0<m<n and Solution:-


d<n. The state space for this problem can be defined as
Output: An integer sequence corresponding to a
feasible solution obtained by filling the m-litre jug and { ( i ,j ) i = 0,1,2,3,4 j = 0,1,2,3}
n-litre jug.
Procedure: 1. Set the value of the variable c to the „i‟ represents the number of liters of water in the 4-
larger of the two values a and b and set d to the liter jug and „j‟ represents the number of liters of
smaller of a and b. 2. Find the quotient and the water in the 3-liter jug. The initial state is ( 0,0) that is
remainder when c is divided by d. Call the quotient q no water on each jug. The goal state is to get ( 2,n) for
and the remainder r. Use the division algorithm and any value of „n‟.
expressions for previous remainders to write an
expression for r in terms of a and b. 3. If r = 0, then To solve this we have to make some assumptions not
gcd(a, b) = d. The expression for the previous value of mentioned in the problem. They are
r gives an expression for gcd(a, b) in terms of a and b.
Stop. 4. Otherwise, use the current values of d and r as 1. We can fill a jug from the pump.
the new values of c and d, respectively, and go back to
step 2. In this algorithm, we will be getting the GCD 2. we can pour water out of a jug to the ground.

International Journal of Scientific Research in Science, Engineering and Technology (ijsrset.com)


332
3. We can pour water from one jug to another.

4. There is no measuring device available.

The various operators (Production Rules) that are


available to solve this problem may be stated as given
in the following figure .

International Journal of Scientific Research in Science, Engineering and Technology (ijsrset.com)


333
IV. CONCLUSION
In Breadth First Search all nodes has to be achievement in the water jug task,” Journal
evaluated and instead of finding a single node we of
will be forced to find many answers and it is waste Cognitive Neuroscience, 13(8), 2001, pp.
of time. It is its main disadvantages. 1129– 1147.
In Depth First Search, this method single and
unfruitful path is being carried out for a very long
[7] D. M. Burdon, Elementary Number Theory,
time and longer path never explored until the
5th edition, NY: McGraw-Hill, 2002.
entire shorter one has been examined.
[8] F. Leon, M. H. Zaharia, and D. Galea, “A
So we choose Diophantine equation here the values
heuristic for solving the generalized water jugs
for both x and y is just assumption so that we have
problem,” Bulletin of the Polytechnic Institute of
to work from the first and by chance if sometimes
Iasi, fasc. 1–4, 2005, pp. 95–102.
the equation satisfies means then we will consider
[9] S. L. Beilock and M.S. DeCaro, “From poor
it. But only by chance we will work on it.
performance to success under stress: working
memory, strategy selection and mathematical
The new approach the Extended Euclidean problem solving under pressure,” Journal of
Approach that is being founded in this paper has
Experimental Psychology, 33(6), 2007, pp.
many and more number of advantages. The first
983– 998.
and the foremost one
[10] H. P. Carder, S. J. Handley and T. J. Perfect,
is we don‟t want to do any guess, by having the
input “Counterintuitive and alternative moves
choice in the water jug tasks,” Brain and
itself we are able to get the output. By using the
Cognition, vol.
Extended Euclidean Approach, we are able to get
66, 2008, pp. 11–20.
the appropriate result with less work, complexity
and memory. We can assure that the answer what
is found out is efficient and effective.

V. REFERENCE

[1] S. Abu Naser, “Developing visualization tool for the teaching AI searching algorithms,”
Information Technology Journal, 7(2),
2008, pp. 350–355.
[2] C. J. McDiarmid and J. R. Alfonsin, “Sharing jugs of wine,” Discrete Mathematics, vol. 125,
1994, pp. 279–287.
[3] G. Polya, How to Solve It. NJ: Princeton University Press, 1945.
[4] H.S.M.Coxeter and S.L.Greitzer, Geometry Revisited. Washington D.C.: The Mathematical
Association of America, 1967.
[5] B. Harvey, Computer Science Logo Style: Symbolic Computing (Vol. I), MA: MIT, 1997.
[6] M. K. Colvin, K. Dunbar and J. Grafman, “The effects of frontal lobe lesions on goal

International Journal of Scientific Research in Science, Engineering and Technology (ijsrset.com)


334

You might also like