Beta
Water Jug Puzzle
21saudiGuy
Loading description...
Algorithms
Graph Theory
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
I think random test cases are on the low and easy side. Care to up the perf constraints?
done.
Initial code has
solve(start, goal)
, which should besolve(cap, goal)
. Starting water state is another thing altogether.corrected now.
What is considered a "invalid input"? It is an open ended question that needs to be specified.
Removed from the description. There won't be any invalid input now (it was meant to check if the goal ≠ sum(C)).
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.
This comment has been hidden.
Changed description now. check if acceptable.
Emptying and filling jug is still described as a valid operation.
Now it's
Is the "a jug is filled" part tested?
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).
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.