Test Result: Escaped (Prisoners, Arrived, Departed)
Test Result: Escaped (Prisoners, Arrived, Departed)
1. day 1: 10 arrived and 0 left, count is 10 and 10 found -> no prisoners escaped.
2. day 2: 16 arrived and 0 left, count is 26 but 25 found -> 1 prisoner escaped.
3. day 3: 15 arrived and 1 left, count is 39 and 39 found -> no prisoners escaped.
4. day 4: 12 arrived and 1 left, count is 50 but 49 found 0> 1 prisoner escaped.
Finally, the function returns the number of escaped prisoners (for the above example, 2).
Note, the size of all lists are the same, and the number of prisoners will not be negative.
NOTE: You are NOT allowed to use built-in sum function!
For example:
Test Result
print(escaped([10, 25, 39, 49], [10, 16, 15, 12], [0, 0, 1, 1])) 2
print(escaped([10, 25, 39, 49, 53, 63], [10, 16, 15, 12, 7, 10], [0, 0, 1,
1, 1, 0]))
Write a function bus_capacity(hop_in, hop_out, capacity) that takes two lists that contains
the number of passengers hopping on and off at each stop and the bus capacity. The
function returns the number of people who missed the bus due to the capacity being full.
The bus is empty at the beginning. Please note, passengers get off FIRST before others hop
on.
For example if hop_in = [4, 7, 2], hop_out = [0, 0, 1] and capacity 5, then:
For example:
Test Result
Note: We will treat all inputted English sentences as valid and does not require beautifying.
For example:
Test Result
eng_text = "sunday lunch was yum but bacon was not cooked properly" 4
print(proportion_converted(eng_text))
For example:
Test Result