Deal with negative cases

This commit is contained in:
lolabird 2024-02-29 15:24:04 -07:00
commit 129e74cbf4

View file

@ -8,6 +8,9 @@ def fillJug(rounds, jugA, jugB, target):
if target > jugA["cap"]: if target > jugA["cap"]:
print("Target is too high. Reducing target to Jug A's capacity.") print("Target is too high. Reducing target to Jug A's capacity.")
target = jugA["cap"] target = jugA["cap"]
if target < 0:
return
if jugA["state"] == target: if jugA["state"] == target:
print("Target reached") print("Target reached")
@ -37,7 +40,7 @@ def fillJug(rounds, jugA, jugB, target):
def main(): def main():
jugA = {"name": "Jug A", "state": 0, "cap": 4} jugA = {"name": "Jug A", "state": 0, "cap": 4}
jugB = {"name": "Jug B", "state": 0, "cap": 3} jugB = {"name": "Jug B", "state": 0, "cap": 3}
target = 2 target = -5
return fillJug(1, jugA, jugB, target) return fillJug(1, jugA, jugB, target)