Python code for Waterbucket Problem