Gates ===== Consider a reservoir with a number of gates that can be open or closed. The number of gates to hove open at a given day depends on three factors: - the number of gates of the reservoir - the supply and demand of electricity for the previous week (in kWh) - the day of the week When supply exceeds demand, only a quarter of the gates is open. Otherwise, the number of gates depends on a parameter called *#b* which is the integer number of 50 kWh blocks in the difference between offer and demand. For example, if the offer is 310 kWh and the demand is 650 kWh, then the difference would be 340 and *#b* would be 6 (if it was 350 then it would be 7). Based on *#b* value, there are three situations that determine the gates to have open: - All gates are opened if *#b* equals or exceeds the total number of gates. - Only half of the gates are opened if *#b* values is between the total number of gates and half of that, both excluded. - Only a third of the gates are opened if *#b* is equal or lower than a half of the number of gates. Independently of all that, if the day is Saturday or Sunday, the number of gates that are open is decremented by two. Finally, there is a security norm by which **at least** one gate must always be open. You are required to implement the following functions in the module :mod:`gates_module` (file :file:`gates_module.py`): The main function is .. py:function:: gates(n, sup, dem, day) such that **given** - ``n``, a positive :class:`int` with the total number of gates. - ``sup``, ``dem``, :class:`int` values of the supply and the demand of the previous week (in kWh), respectively. - ``day``, a 3-char :class:`str` indicating the day of the week ('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'). **returns** an :class:`int` with the number of gates to have open according to the previous norms. For example: .. literalinclude:: gates.test :language: python3 :start-after: --ini :end-before: --fi Doctests are available in the :download:`gates.test` file.