Water Jug problem implementation in Python