What! Only Two Pots?

Ron has a super large empty pot. In each operation, he can either pour 173 liters of water into the pot or remove 271 liters of water from the pot if there is enough left.

What is the minimum number of operations needed so that the pot has exactly 1 liter of water left?


The answer is 77.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Arulx Z
Aug 26, 2016

Relevant wiki Linear Diophantine Equations


This problem can be translated as

Find integers x x , y y such that 173 x + 271 y = 1 173x+271y=1 and x + y |x|+|y| is minimal.

Firstly, it's important to note that a solution exists because gcd ( 173 , 271 ) 1 \gcd(173,271) | 1 .

It is well known that once a single solution of this equation is found, infinitely many solutions can be found. In fact,

x = x 1 + 271 n y = y 1 173 n x = x_1 + 271n \\ y = y_1 - 173n

provide all the solutions for some integer n n and a solution ( x 1 , y 1 ) (x_1, y_1) . But finding a single solution looks like a task difficult enough because guessing gives no luck.

However, Bezout's lemma (backtracking Extended Euclidean Algorithm) provides an easy way to find the solution. On performing the process, ( x , y ) = ( 47 , 30 ) (x,y)=(47,-30) can be obtained. Now we just need to find the minimum solution. Using the previously obtained formula,

x = 47 + 271 n y = 39 173 n x = 47 + 271n \\ y = -39 - 173n

provides all the solutions. It is not hard to see that when n 1 |n| \geq 1 , x + y |x| + |y| increases monotonically. Hence the minimal value occurs when n = 0 n=0 . x = 47 x=-47 and y = 30 y=30 is indeed the minimum, and so the answer is 30 + 47 = 77 |30|+|-47| = 77 .

Can u pleaseexplain this in simple and more descriptively plzz

Shravani Sardeshpande - 4 years, 9 months ago

Log in to reply

What part exactly?

Arulx Z - 4 years, 9 months ago

Log in to reply

Hey did you give NMTC today?

Kushagra Sahni - 4 years, 9 months ago

Log in to reply

@Kushagra Sahni No. I wasn't aware of it.

Arulx Z - 4 years, 9 months ago
Manuel Kahayon
Aug 27, 2016

I just got this weird solution, by instinct. I actually wonder why it works (can someone explain, please?) We get that 173 x 271 y = 1 173x-271y = 1 .

Now, we get the coefficients and transform it into an ordered pair, ( 173 , 271 ) (173, 271) . We then replace the larger of the two elements of the ordered pair and replace it with its residue modulo the smaller one. i.e.

( 173 , 271 ) ( 173 , 271 ( m o d 173 ) ) ( 173 , 98 ) (173, 271) \implies (173, 271 \pmod{173}) \implies (173, 98) .

We continue doing this until we get

( 173 , 271 ) ( 173 , 98 ) ( 75 , 98 ) ( 75 , 23 ) ( 6 , 23 ) ( 6 , 5 ) (173, 271) \implies (173, 98) \implies (75, 98) \implies (75, 23) \implies (6, 23) \implies (6,5)

And we stop there, since 6 5 = 1 6-5 = 1 . Again, I have no idea why this works.

Next, we start off using the fact that ( 6 5 = 1 ) (6-5 = 1) and use that and the ordered pairs ( 173 , 271 ) , ( 173 , 98 ) , ( 75 , 98 ) , ( 75 , 23 ) , ( 6 , 23 ) , ( 6 , 5 ) (173, 271) , (173, 98) , (75, 98) , (75, 23) , (6, 23) , (6,5)

6 5 = 1 6 23 + 18 = 6 23 + 3 ( 6 ) = 1 4 ( 6 ) 23 = 1 6-5 = 1 \implies 6 - 23 + 18 = 6 - 23 + 3(6) = 1 \implies 4(6) - 23 = 1

Can you see where I am going with this?

4 ( 6 ) 23 = 4 ( 75 69 ) 23 = 4 ( 75 ) 12 ( 23 ) 23 = 4 ( 75 ) 13 ( 23 ) = 1 4(6) - 23 = 4(75 - 69) - 23 = 4(75) - 12(23) - 23 = 4(75) - 13(23) = 1 .

4 ( 75 ) 13 ( 23 ) = 4 ( 75 ) 13 ( 98 75 ) = 4 ( 75 ) + 13 ( 75 ) 13 ( 98 ) = 17 ( 75 ) 13 ( 98 ) = 1 4(75) - 13(23) = 4(75) - 13(98 - 75) = 4(75) + 13(75)- 13(98) = 17(75) - 13(98) = 1 .

17 ( 75 ) 13 ( 98 ) = 17 ( 173 98 ) 13 ( 98 ) = 17 ( 173 ) 13 ( 98 ) 17 ( 98 ) = 17 ( 173 ) 30 ( 98 ) = 1 17(75) - 13(98) = 17(173 - 98) - 13(98) = 17(173) - 13(98) - 17(98) = 17(173) - 30(98) = 1 .

17 ( 173 ) 30 ( 98 ) = 17 ( 173 ) 30 ( 271 173 ) = 47 ( 173 ) 30 ( 271 ) = 1 17(173) - 30(98) = 17(173) - 30(271 - 173) = \boxed{47(173) - 30(271) = 1}

Therefore, removing water 30 30 times and adding water 47 47 times will fill the pot with one liter, assuming Ron will have something to do with that liter and a large pot capable of holding a lot of water (One can actually make a problem out of this, what is the smallest possible capacity of the pot such that this insanity can be made possible). Anyways, there are a total of 30 + 47 = 77 30 + 47 = 77 actions, so our answer is 77 \boxed{77} .

Our solutions are identical. In the first part, where you are reducing ( 173 , 271 ) (173,271) , you are essentially performing Extended Euclidean Algorithm by using the fact that ( a , b ) = ( a m o d b , b ) (a, b) = (a \bmod b, b) . In the second part, you are backtracking the Euclidean Algorithm to solve the Diophantine equation.

Getting this far by instinct is bizarre.

Arulx Z - 4 years, 9 months ago

Log in to reply

Really? Thanks for the explanation... So that was what the extended euclidean algorithm was... I only know the Euclidean algorithm for finding GCF's. Also, it's not that bizarre, since I already (sort of) knew this will work, since I do something similar when dealing with modulos, kind of hard to explain, really.

Manuel Kahayon - 4 years, 9 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...