Water Tanks =========== Let's consider a *water tank* with a limited capacity which received a number of water contributions at different times. When the water accumulated exceeds the tank capacity there is *tank overflow* and the excess water is lost. This information is represented in a list of three values: - the tank name - the tank capacity - a list quantities of water contributions In this context, you are required to deliver the following functions in the module :mod:`tanks` (file :file:`tanks.py`). ------------------------------------------------------------------------------------------------ The first function is: .. py:function:: fill_up(capacity, Lc) such that **given** *capacity*, a positive :class:`int`, and ``cL`` a :class:`list` of positive :class:`int` **returns** two values: - a :class:`bool` which is ``True`` is the tank got filled up (the water accumulated by the sequence of contributions in *cL* reached or exceeded the *capacity*, and ``False`` otherwise. - an :class:`int` which is either the number of water contributions from *cL* needed to reach the tank's capacity, or *0* if the tank did not get full. For example: .. literalinclude:: fill_up.test :language: python3 :start-after: --ini :end-before: --fi Doctests are available in the :download:`fill_up.test` file. ------------------------------------------------------------------------------------------------ The second function is: .. py:function:: select_full(tL) such that **given** *tL* a :class:`list` of lists where each sublist is the information of a water tank as described above **returns** a new :class:`list` of :class:`tuple` where each tuple corresponds to a tank in *tL* that got full and has two values: - a :class:`str` with the tank name of the tank - a :class:`int` with the the number of water contributions needed to fill the tank up to the top. For example: .. literalinclude:: select_full.test :language: python3 :start-after: --ini :end-before: --fi Doctests are available in the :download:`select_full.test` file. .. note:: Implementing this function by calling the ``fill_up`` function is recommended to save time. ------------------------------------------------------------------------------------------------ The third function is: .. py:function:: update_full(tL) such that **given** *tL* a :class:`list` of lists where each sublist is the information of a water tank as described above **updates** *tL* by modifying the list of contributions leaving exactly the ones that fill the tank capacity. Therefore, the contributions after the tank being full should be deleted. The last contribution that filled up the tank must be updated in order to exactly fill the tank capacity. The tanks that did not reach its full capacity will not be modified. For example: .. literalinclude:: update_full.test :language: python3 :start-after: --ini :end-before: --fi Observe that the last contribution in ``'Nou Barris'`` tank changed from 10 to 1 in order to have the sum of the list of contributions exactly the tank capacity of 10, as opposed to 'Carel tank which did not change. Doctests are available in the :download:`update_full.test` file. .. note:: Implementing this function by calling the ``fill_up`` function is recommended to save time.