Artists Tours ============= We have the programs of the music festival are stored in a dictionnary, let's call it ``fest_D``, where the key is the name of the festival (:class:`str`) and the value is a list of the "days" of the festival. Each day is in turn a list where the first component is the calendar date (which is a 3-:class:`int` tuple: the year, the month and the day) and the rest are the artist names (:class:`str`) scheduled to perform that date. See the following example: .. literalinclude:: gen_tour_D-test.txt :language: python3 :start-after: --ini-dic :end-before: --fi-dic Notice that ``Canet Rock`` festival takes only one day whereas the ``Vida`` festival takes three days: 2023/7/1, 2023/7/2 and 2023/7/3, and several artists are scheduled each of they. Also we know that an artist is scheduled for at most one gig for festival. Our purpose is, given a dict with the programs of a number of music festivals and a list of artist names (:class:`str`), to generate for each of those artists its tour of gigs in those festivals. Namely, we want to generate a :class:`dict`, let's call it ``tour_D``, whose keys are the artists names and the associated value is an ordered :class:`list` of the gigs for that artist, where each gig is a 2-value tuple with the date of the gig (which in turn is a 3-int tuple) and the name of the festival (:class:`str`). The order of the list is **increasing by date**. For example: .. literalinclude:: gen_tour_D-test.txt :language: python3 :start-after: --ini-tests :end-before: --fi-tests ----------------------------------------------------------------------------------- Now, to solve this problem it is **mandatory** to create the module :mod:`tours` (file :file:`tours.py`) and write the functions specified in the following steps: **Step #1**. Write a function to find an artist in a list of days: .. py:function:: find_art(art, fest_dates_L) such that *given* - ``art`` is a :class:`str` with the name of an artist - ``fest_dates_L`` is a list "dates" as the ones in the values of dict ``fest_D`` described above *returns* either a 3-:class:`int` tuple with the first date when that artist is scheduled or the empty tuple ``()`` is the artist does not appear in any sublist. For example: .. literalinclude:: find_art-test.txt :language: python3 Test sets are available in the file :download:`find_art-test.txt `. ----------------------------------------------------------------------------------- **Step #2**. Write and test the following function to construct a dict of not necessarily ordered tours, by calling the previous function: .. py:function:: cnst_tour_D(fest_D, art_L) such that *given* - ``fest_D`` a :class:`dict` as described above - ``art_L`` is a list of :class:`str` with artist names *returns* a ``tour_D`` :class:`dict` as described above where the tours associated with each artist are **not necessarily ordered**. For example: .. literalinclude:: cnst_tour_D-test.txt :language: python3 :start-after: --ini-tests :end-before: --fi-tests Test sets are available in the file :download:`cnst_tour_D-test.txt `. ----------------------------------------------------------------------------------- **Step #3**. Write and test a function to order the tours: .. py:function:: sort_tour_D(tour_D) such that *given* - ``tour_D`` a :class:`dict` as described above, **modifies** it by ordering increasingly by date, every tour associated with its artists. For example: .. literalinclude:: sort_tour_D-test.txt :language: python3 Test sets are available in the file :download:`sort_tour_D-test.txt `. ----------------------------------------------------------------------------------- **Step #4**. Finally write and test the function .. py:function:: gen_tour_D(fest_D, art_L) such that *given* - ``fest_D`` a dictionnary as describe above - ``art_L`` is a list of :class:`str` with artist names *returns* a ``tour_D`` :class:`dict` whose keys are the artists in ``art_L`` and the associated value is an **ordered** :class:`list` of the artist's gigs as described above. The order of all the gigs list is **increasing by date**. See the example at the beginning of this statement. Test sets are available in the file :download:`gen_tour_D-test.txt `.