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

출처

Wikipedia링크가 새 창이나 탭에서 열려요
GitHub에서 편집 링크가 새 창이나 탭에서 열려요
Factor Exercism

먹이 사슬 문제를 시작해 볼 준비가 됐나요?

Exercism에 가입하고 Factor 트랙을 개념 47개연습 문제 163개, 그리고 실제 사람의 멘토링과 함께 배우고 익혀 보세요. 모두 무료예요.