Kurzusok
/
Python
Python
/
Feladatok
/
Tizenkét nap
Tizenkét nap

Tizenkét nap

Könnyű

Utasítások

Ebben a feladatban olyan kódot kell írnod, amely visszaadja a(z) »The Twelve Days of Christmas« című dal szövegét.

A »The Twelve Days of Christmas« egy közismert angol karácsonyi dal. A dal minden további versszaka az előző versszakra épül.

A kódod által visszaadott dalszövegnek pontosan meg kell egyeznie az alább látható teljes dalszöveggel.

Dalszöveg

On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree.

On the second day of Christmas my true love gave to me: two Turtle Doves, and a Partridge in a Pear Tree.

On the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.

On the fourth day of Christmas my true love gave to me: four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.

On the fifth day of Christmas my true love gave to me: five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.

On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.

On the seventh day of Christmas my true love gave to me: seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.

On the eighth day of Christmas my true love gave to me: eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.

On the ninth day of Christmas my true love gave to me: nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.

On the tenth day of Christmas my true love gave to me: ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.

On the eleventh day of Christmas my true love gave to me: eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.

On the twelfth day of Christmas my true love gave to me: twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.

Tesztvezérelt fejlesztés

Mindenképpen nézd meg a teszfájl elején lévő megjegyzéseket. Segítenek megérteni, milyen kimenetet vár a függvényedtől.

Ezt a kihívást meg lehetne oldani minimális kóddal és rengeteg beégetett szöveggel, amely a versszakok között ismétlődik. Ez a dal viszont egyfajta halmozó dal, amelyben minden új versszak az előtte lévőre épül. Ha nagyobb programozási kihívásra vágysz, próbáld meg az egyes versszakokat a részeikből összeállítani. Például minden versszakban változik a nap és változik az ajándék, a versszak többi része pedig nagyjából ugyanaz. Milyen jó stratégia lehet az ismétlés elkerülésére?


Forrás

WikipediaA hivatkozás új ablakban vagy lapon nyílik meg
Szerkesztés GitHubon A hivatkozás új ablakban vagy lapon nyílik meg
Python Exercism

Készen állsz elkezdeni a(z) Tizenkét nap feladatot?

Iratkozz fel az Exercism-re, hogy megtanuld és elsajátítsd a(z) Python nyelvet 17 fogalom146 feladat segítségével, valódi emberi mentorálással, mindez ingyen.