In a sequence of words, a word is said to be chained when it starts with the last letter of the previous word.
When
consecutive words satisfy this condition, we say there is a
streak of length
.
For example, given the sequence
["sol", "lobo", "oso", "ojo", "gato"] there is a streak of
4 words from "sol" to "ojo".
Design a function rachas(listapals) that, given a list
of words listapals, returns all the streaks appearing in
the list, in the order in which they appear. Each streak must be
represented as a list of at least two consecutive words that satisfy the
chaining condition.
>>> rachas(['inicio','hola', 'adios', 'silla', 'patata']) [['hola', 'adios', 'silla']] >>> rachas(['inicio','ola', 'casa', 'adios', 'silla', 'patata']) [['inicio','ola'], ['casa', 'adios', 'silla']]