المسارات
/
Factor
Factor
/
التمارين
/
السلسلة الغذائية
السلسلة الغذائية

السلسلة الغذائية

متوسط

التعليمات

أنشئ كلمات أغنية «I Know an Old Lady Who Swallowed a Fly».

يمكنك أن تنسخ الكلمات وتلصقها، أو أن تقرأها من ملف، لكن هذه المسألة تصبح أكثر إمتاعًا بكثير إذا تعاملت معها بطريقة خوارزمية.

هذه أغنية تراكمية مجهولة الأصل.

وهي واحدة من صيغ شائعة عديدة.

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!

تفاصيل Factor

نفّذ الكلمة:

food-chain ( start end -- lines )

start وend هما رقما المقطع (1 للذبابة، حتى 8 للحصان)، شاملًا. أرجع المقاطع المطلوبة كتسلسل من السلاسل النصية، بحيث تمثل كل سلسلة سطرًا واحدًا من الأغنية.

عندما يُطلب أكثر من مقطع واحد، افصل بين المقاطع المتتالية بسلسلة نصية فارغة واحدة ("") بحيث تُعرض المقاطع مع سطر فارغ بينها. لا يوجد سطر فارغ في النهاية بعد المقطع الأخير.

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."
!    }

المصدر

ويكيبيديايفتح الرابط في نافذة أو علامة تبويب جديدة
تعديل عبر GitHub يفتح الرابط في نافذة أو علامة تبويب جديدة
Factor Exercism

مستعد لبدء السلسلة الغذائية؟

سجّل في Exercism لتتعلّم وتتقن Factor عبر 47 مفهومًا163 تمرينًا، وإرشاد بشري حقيقي، وكل ذلك مجانًا.