Etiquetas hash para titulares

Published by Helen Yu in

Escribe una función que obtenga las 3 palabras más largas de un titular de periódico y las transforme en hashtags. Si varias palabras tienen la misma longitud, obtén la palabra que aparece primero.

Ejemplos

get_hash_tags("How the Avocado Became the Fruit of the Global Trade")
➞ ["#avocado", "#became", "#global"]

get_hash_tags("Why You Will Probably Pay More for Your Christmas Tree This Year")
➞ ["#christmas", "#probably", "#will"]

get_hash_tags("Hey Parents, Surprise, Fruit Juice Is Not Fruit")
➞ ["#surprise", "#parents", "#fruit"]

get_hash_tags("Visualizing Science")
➞ ["#visualizing", "#science"]

Notas

  • Si el titular tiene menos de 3 palabras, simplemente ordena las palabras del titular por longitud en orden descendente (consulta el ejemplo n.º 4).
  • La puntuación no cuenta para la longitud de una palabra.