Prize37 Chapter 5, Exercise 1 Order of operations for one boat up a three-lock flight Task Plan the order of operations for one boat going up a flight of three narrow locks with a short pound between each pair, using the timings of this chapter. List the clock time at which the boat enters and leaves each lock, when each lock is ready again after it has been emptied, and how much water the summit pound loses for one passage. (assumed figures throughout) Code (run with Python) enter, shut, fill, open_, leave = 2, 1, 6, 1, 2 # minutes (assumed) between, reset = 3, 6 lock_time = enter + shut + fill + open_ + leave volume = round(21.0 * 2.1 * 2.4, 1) t = 0 for name, source in [("lower", "pound 1"), ("middle", "pound 2"), ("upper", "the summit pound")]: print("t =", t, ": boat enters the", name, "lock, which fills from", source) t += lock_time print("t =", t, ": boat leaves the", name, "lock; reset it by emptying it, ready at t =", t + reset) t += between print("water drawn from the summit pound per passage (m3):", volume) print("flight ready for the next boat when the last reset ends (min):", lock_time * 3 + between * 2 + reset) Output (exactly as printed) t = 0 : boat enters the lower lock, which fills from pound 1 t = 12 : boat leaves the lower lock; reset it by emptying it, ready at t = 18 t = 15 : boat enters the middle lock, which fills from pound 2 t = 27 : boat leaves the middle lock; reset it by emptying it, ready at t = 33 t = 30 : boat enters the upper lock, which fills from the summit pound t = 42 : boat leaves the upper lock; reset it by emptying it, ready at t = 48 water drawn from the summit pound per passage (m3): 105.8 flight ready for the next boat when the last reset ends (min): 48 Answer The boat is in the lower lock from t = 0 to t = 12 (2 to enter, 1 to close, 6 to fill from pound 1, 1 to open, 2 to leave), crosses pound 1 in 3 minutes, is in the middle lock from 15 to 27 and in the upper lock from 30 to 42. As soon as the boat has left a lock, that lock is emptied into the pound below it (6 minutes), which both resets it and puts back the water its own filling took from that pound. The lower lock is ready at 18, the middle at 33 and the upper at 48. Only the upper lock is filled from the summit pound, so one passage costs one chamber, 21.0 x 2.1 x 2.4 = 105.8 cubic metres, which ends up in the bottom pound. The middle pounds lose and regain the same chamber of water. The sum assumes the pounds are big enough that their levels barely move.