Beta

Water Jug Puzzle

Description
Loading description...
Algorithms
Graph Theory
  • Please sign in or sign up to leave a comment.
  • dfhwze Avatar

    I think random test cases are on the low and easy side. Care to up the perf constraints?

  • Voile Avatar

    Initial code has solve(start, goal), which should be solve(cap, goal). Starting water state is another thing altogether.

  • Voile Avatar

    If the inputs are invalid or there is no solution, return -1.

    What is considered a "invalid input"? It is an open ended question that needs to be specified.

    • saudiGuy Avatar

      Removed from the description. There won't be any invalid input now (it was meant to check if the goal ≠ sum(C)).

      Issue marked resolved by saudiGuy 2 years ago
  • Mercy Madmask Avatar

    The first two operations are not allowed, the solution expects you to never empty or fill a jug, only move water from one to another.

    This explains why you have the note The total liters in the goal state must be equal to the capacity of jug "C".
    But this should be clarified.

    • Mercy Madmask Avatar

      This comment has been hidden.

    • saudiGuy Avatar

      Changed description now. check if acceptable.

      Issue marked resolved by saudiGuy 2 years ago
    • Voile Avatar

      An operation is any of the following: A jug is emptied, a jug is filled, or water is poured from one jug to another until one of the jugs is either empty or full.

      Emptying and filling jug is still described as a valid operation.

    • Voile Avatar

      Now it's

      An operation is any of the following: A jug is filled, or water is poured from one jug to another until one of the jugs is either empty or full.

      Is the "a jug is filled" part tested?

  • hobovsky Avatar

    Please verify potential duplicate: https://www.codewars.com/kata/61de6142b31ff7000cc27e10 (I didnt solve either of the kata, I just remembered that there already exists a kata with Bruce Willis).

    • dfhwze Avatar

      That kata looks like a warmup for this one. Though some solutions on that one don't need much refactoring to pass this one. I'd say they are different enough.