GreatNoise X47293


Statement
 

pdf   zip

html

The music platform GreatNoise.com wants to improve the service it offers to their subscribers. To do this, it will add different functionalities that users will be able to use in their playlists.

A playlist consists of a list of one or more songs, which are both lists with the following elements:

  • Song title (str)
  • Author or group (str)
  • Album title (str)
  • Duration in seconds (int)

The three statements below are related but can be solved independently, without depending any of them on the solution of the others.

  1. GreatNoise.com wants to show the total duration of a reproduction list. Program a function calcula_duracion(lista_reproduccion) that from lista_reproduccion, a list like the ones described at the beginning, returns the total duration in minutes and seconds from the list provided.
  2. GreatNoise.com also wants the user to have more information about the added songs in the list. Program a function clasificar_duracion(lista_reproduccion) that, from from lista_reproduccion, a list like the ones described at the beginning, returns a dictionary that counts by duration the songs in the list according to the following criteria:
    1. less than 3 minutes
    2. between 3 and 5 minutes (included)
    3. more than 5 minutes

    Use the letters ’a’, ’b’, and ’c’ as dictionary keys.

  3. Finally, GreatNoise.com wants to calculate statistics on the playlists. Program a function estadisticas(lista_reproduccion) that from lista_reproduccion, a list like the ones described at the beginning, returns a dictionary that associates the song titles in the playlist with a list composed by the author and all albums (they can be repeated) in which the song appears in the playlist.

Scoring

Apartado 1: 33 puntos.

Apartado 2: 33 puntos.

Apartado 3: 34 puntos.

Sample session
>>> lista = [["Higher", "Creed", "Greatest Hits", 316],
...          ["Basket Case", "Green Day", "Dookie", 182],
...          ["Glycerine", "Bush", "Sixteen Stone", 266],
...          ["Congregation", "Foo Fighters", "Sonic Highways", 312],
...          ["Blackbird", "Alter Bridge", "Blackbird", 478],
...          ["Basket Case", "Green Day", "God's FB", 182],
...          ["Fuck You", "Bad Religion", "True North", 134],
...          ["Higher", "Creed", "Human Clay", 316]]
>>> calcula_duracion(lista)
(36, 26)

>>> clasificacion = clasificar_duracion(lista)
>>> clasificacion == {'a': 1, 'b': 3, 'c': 4}
True

>>> lista = [["Higher", "Creed", "Greatest Hits", 316],
...          ["Basket Case", "Green Day", "Dookie", 182],
...          ["Glycerine", "Bush", "Sixteen Stone", 266],
...          ["Congregation", "Foo Fighters", "Sonic Highways", 312],
...          ["Blackbird", "Alter Bridge", "Blackbird", 478],
...          ["Basket Case", "Green Day", "God's FB", 182],
...          ["Fuck You", "Bad Religion", "True North", 134],
...          ["Higher", "Creed", "Human Clay", 316]]
>>> canciones = estadisticas(lista)
>>> canciones == {'Higher': ['Creed', 'Greatest Hits', 'Human Clay'],
...               'Basket Case': ['Green Day', 'Dookie', "God's FB"],
...               'Glycerine': ['Bush', 'Sixteen Stone'],
...               'Congregation': ['Foo Fighters', 'Sonic Highways'],
...               'Blackbird': ['Alter Bridge', 'Blackbird'],
...               'Fuck You': ['Bad Religion', 'True North']}
True
Information
Author
InfBesos
Language
English
Translator
Original language
Spanish
Other languages
Catalan Spanish
Official solutions
Python
User solutions
Python