Streaks W93601


Statement
 

pdf   zip   main.py

In a sequence of words, a word is said to be chained when it starts with the last letter of the previous word.

When kk consecutive words satisfy this condition, we say there is a streak of length kk. 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.

Sample session

Sample session
>>> rachas(['inicio','hola', 'adios', 'silla', 'patata'])
[['hola', 'adios', 'silla']]
>>> rachas(['inicio','ola', 'casa', 'adios', 'silla', 'patata'])
[['inicio','ola'], ['casa', 'adios', 'silla']]
Information
Author
infbesos
Language
English
Translator
infbesos
Original language
Spanish
Other languages
Catalan Spanish
Official solutions
Python
User solutions