Time control ============ A factory uses a time stamping system that controls its employees entry and exit times and these data is recorded daily into a file. Each entry or exit of an employee results in a line of this file with the following data: NIF, name and surname, the entry or exit time (in format HH:MM) and a character that indicates whether the employee entered or left work (``'E'`` or ``'L'``). These data are separated by ``', '`` (comma-whitespace) and lines are ordered chronologically. The file contains two initial lines that describe the fields. For example: .. literalinclude:: examples/entryexit.txt :language: python You can download the example file :download:`entryexit.txt` Save these functions into a file named ``control.py``. #. Write the function :py:func:`control` that given the name of a file as described above and an integer indicating a time (hour), ``h``, returns the number of workers that have entered to work between ``h`` (included) and ``h+1`` (excluded). Examples: .. literalinclude:: test-control.txt :language: python3 :lines: 3- .. note:: More tests are provided in file :download:`test-control.txt` #. Write the function :py:func:`add_time` that given 4 integers corresponding to the hours and minutes of a first time and the hours and minutes of a second time, returns two integers corresponding to the hours and minutes of the sum of the two given times. Hours and minutes must be positive and minutes must be less than 60. Examples: .. literalinclude:: add_time.txt :language: python3 :lines: 3- .. note:: More tests are provided in file :download:`add_time.txt` #. Write the function :py:func:`subtract_time` that given 4 integers corresponding to the hours and minutes of a first time and the hours and minutes of a second time, returns two integers corresponding to the hours and minutes of the difference between the first time and the second time. Hours and minutes must be positive and minutes must be less than 60. Examples: .. literalinclude:: subtract_time.txt :language: python3 :lines: 3- .. note:: More tests are provided in file :download:`subtract_time.txt` #. Write the function :py:func:`control_1` that given the name of a file as described above and the NIF of a worker of the company, calculates how long this worker has been working. The function must return two integers corresponding to the hours and minutes of the working time. This function must use the previous two. A worker may come in and out more than once. Examples: .. literalinclude:: test-control_1.txt :language: python3 :lines: 3- .. note:: More tests are provided in file :download:`test-control_1.txt` #. Write the function :py:func:`control_2` that given the name of a file as described above and the NIF of the factory CEO, returns ``True`` if, and only if, the CEO has been the last one to come into work. If the CEO did not come into work, the function must also return ``True``. With the given data, if the CEO is Maria Sans, the function has to return ``True``; however, if the CEO is any of the other four employees, the function must return ``False``. Tip: build an auxiliary dictionary in which the key is the NIF and the value the first time that the worker has come into work. Examples: .. literalinclude:: test-control_2.txt :language: python3 :lines: 3- .. note:: More tests are provided in file :download:`test-control_2.txt` .. rubric:: Solutions A solution of these functions is provided in file :download:`control.py `