From ea11be85608543b31f4fdd62f164cba1e5e6d4d2 Mon Sep 17 00:00:00 2001 From: lolabird Date: Thu, 29 Feb 2024 15:21:18 -0700 Subject: [PATCH] Account for cases where the target is higher than Jug A's capacity --- thinkcspy/Chapter-16-Exercises/Problem9and10_gallons.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/thinkcspy/Chapter-16-Exercises/Problem9and10_gallons.py b/thinkcspy/Chapter-16-Exercises/Problem9and10_gallons.py index f1af4ac..bb5653a 100644 --- a/thinkcspy/Chapter-16-Exercises/Problem9and10_gallons.py +++ b/thinkcspy/Chapter-16-Exercises/Problem9and10_gallons.py @@ -5,6 +5,10 @@ def fillJug(rounds, jugA, jugB, target): pour = 0 + if target > jugA["cap"]: + print("Target is too high. Reducing target to Jug A's capacity.") + target = jugA["cap"] + if jugA["state"] == target: print("Target reached") return