Gera a letra da canção «I Know an Old Lady Who Swallowed a Fly».
Embora possas copiar e colar a letra, ou lê-la de um ficheiro, este problema é muito mais interessante se o abordares de forma algorítmica.
Esta é uma canção cumulativa de origem desconhecida.
Esta é uma de muitas variantes comuns.
I know an old lady who swallowed a fly.
I don't know why she swallowed the fly. Perhaps she'll die.
I know an old lady who swallowed a spider.
It wriggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly.
I don't know why she swallowed the fly. Perhaps she'll die.
I know an old lady who swallowed a bird.
How absurd to swallow a bird!
She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly.
I don't know why she swallowed the fly. Perhaps she'll die.
I know an old lady who swallowed a cat.
Imagine that, to swallow a cat!
She swallowed the cat to catch the bird.
She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly.
I don't know why she swallowed the fly. Perhaps she'll die.
I know an old lady who swallowed a dog.
What a hog, to swallow a dog!
She swallowed the dog to catch the cat.
She swallowed the cat to catch the bird.
She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly.
I don't know why she swallowed the fly. Perhaps she'll die.
I know an old lady who swallowed a goat.
Just opened her throat and swallowed a goat!
She swallowed the goat to catch the dog.
She swallowed the dog to catch the cat.
She swallowed the cat to catch the bird.
She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly.
I don't know why she swallowed the fly. Perhaps she'll die.
I know an old lady who swallowed a cow.
I don't know how she swallowed a cow!
She swallowed the cow to catch the goat.
She swallowed the goat to catch the dog.
She swallowed the dog to catch the cat.
She swallowed the cat to catch the bird.
She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly.
I don't know why she swallowed the fly. Perhaps she'll die.
I know an old lady who swallowed a horse.
She's dead, of course!
Implementa a palavra:
food-chain ( start end -- lines )
Os start e end são números de verso (1 para a mosca, até 8 para o cavalo), inclusive. Devolve os versos pedidos como uma sequência de strings, uma string por linha da canção.
Quando é pedido mais do que um verso, separa os versos consecutivos com uma única string vazia (""), para que os versos sejam apresentados com uma linha em branco entre eles. Não há linha em branco no final, depois do último verso.
1 2 food-chain .
! => {
! "I know an old lady who swallowed a fly."
! "I don't know why she swallowed the fly. Perhaps she'll die."
! ""
! "I know an old lady who swallowed a spider."
! "It wriggled and jiggled and tickled inside her."
! "She swallowed the spider to catch the fly."
! "I don't know why she swallowed the fly. Perhaps she'll die."
! }
Inscreve-te no Exercism para aprenderes e dominares Factor com 47 conceitos163 exercícios, e mentoria humana real, tudo grátis.