← RoseCode

ROSECODE 368

Die Hard

Philippe_57721 · Programming ·

In the movie Die Hard 3, Officer John McLane has to stop a bomb to explode by using a conterweight of 4 gallons.

For this, he can only use 2 jugs of 5 and 3 gallons.
He can do it in 6 moves:
  1. [ 5 ] [ 0 ] // Pour 5 gallons in the 1st jug
  2. [ 2 ] [ 3 ] // Fill the 2nd jug with the 1st
  3. [ 2 ] [ 0 ] // Empty the 2nd jug
  4. [ 0 ] [ 2 ] // Pour the 2 gallons from the 1st jug to the 2nd
  5. [ 5 ] [ 2 ] // Pour 5 gallons the 1st jug
  6. [ 4 ] [ 3 ] // Fill the 2nd jug with the 1st => We are done: 4 gallons remain in the 1st jug

- How many moves (M1) would Officer McLane need to weight 641 gallons with 2 jugs of 19937 and 23209 gallons?
- Which capacity (C2) between 1 and 19936 requieres the largest number of moves (M2)?

[Answer format: M1,C2,M2

[My timing: 4 sec]