Marathon ======== The results of marathon races are stored in files with the following structure: the first line contains a header detailing the meaning of each data field in the file and the following lines correspond to a participant each and have the following data fields: surname (:class:`str`), racing time (hours, minutes and seconds, three integers (:class:`int`)) and country (:class:`str`), separated by a space. File :download:`marathon.txt` is an example of this kind of files, with the following content: .. literalinclude:: examples/marathon.txt :language: console Save the following functions into file ``marathon.py``. #. Write the function :py:func:`convert` that given the name of a file with the results of a marathon (:class:`str`), returns a :class:`list` of tuples (:class:`tuple`) where each tuple corresponds to a participant and contains the surname (:class:`str`), the racing time *converted to seconds* (:class:`int`) and the country (:class:`str`). Participants in this list must be in the same order as the file. Example: .. literalinclude:: test-convert.txt :language: python3 :lines: 3- .. note:: More tests are provided in file :download:`test-convert.txt` #. Write the function :py:func:`time_under` that given a :class:`list` of tuples (:class:`tuple`) such as that returned by function :py:func:`convert` and a time, ``t``, in seconds (:class:`int`), returns ``True`` if there is at least one runner that has made a time below ``t``, and ``False`` otherwise. Example: .. literalinclude:: test-time_under.txt :language: python3 :lines: 3- .. note:: More tests are provided in file :download:`test-time_under.txt` #. Write the function :py:func:`first_difference` that given :class:`list` of tuples (:class:`tuple`) as that returned by function :py:func:`convert` and the name of a file (:class:`str`), creates a file with the given name where each line represents one runner and includes the surname (:class:`str`) and the time difference with the first classified, in seconds (:class:`int`), separated by a space. We can suppose that the given list is sorted increasingly by time. The first runner must also appear in the file with a time difference of 0. Examples: .. literalinclude:: test-first_difference.txt :language: python3 :lines: 3- .. note:: More tests are provided in file :download:`test-first_difference.txt` .. rubric:: Solutions A solution of these functions is provided in file :download:`marathon.py `