in reply to Re^2: Challenge: N Jugs Problem
in thread Challenge: N Jugs Problem

How many steps do you see? And how much water is consumed?

  1. Fill Y pour Z
  2. Fill Y pour Z
  3. Fill X from Z and return to resevoir.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^4: Challenge: N Jugs Problem
by ikegami (Patriarch) on Apr 14, 2009 at 23:07 UTC

    How many steps do you see?

    According to the OP's definition, there are 6 steps in your program.

    • S → Y (fill Y from supply)
    • Y → Z (pour Y into Z)
    • S → Y (fill Y from supply)
    • Y → Z (pour Y into Z)
    • Z → X (fill X from Z)
    • X → S (pour X into supply)

    The last step is useless, though.

    And how much water is consumed?

    Consumed is ambiguous. The OP asked to minimize how much water is needed. Your program requires 14 units of water (2*Y).

Re^4: Challenge: N Jugs Problem
by JavaFan (Canon) on Apr 14, 2009 at 23:03 UTC
    That's 5 steps (fill Y, pour Y in Z are two separate steps), and in total 14 water is used (filling Y twice). Essentially, it's doing the same as the solution I provided: fill Y twice to collect 14, subtract the content of X making 11.