waterbucket puzzle solved in python and javascript