Sha256: 9c67426cc7b94d8512ad2477b5b4c5b3b6e03d70a4a4862e0b21140e9d0b60b6

Contents?: true

Size: 965 Bytes

Versions: 55

Compression:

Stored size: 965 Bytes

Contents

GIFTS = ['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',
         'a Partridge in a Pear Tree']

ORDINAL = [None, 'first', 'second', 'third', 'fourth', 'fifth', 'sixth',
           'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth']


def verse(day_number):
    gifts = GIFTS[-day_number:]
    if len(gifts) > 1:
        gifts[:-1] = [', '.join(gifts[:-1])]
    gifts = ', and '.join(gifts)
    return 'On the {} day of Christmas my true love gave to me, {}.\n'.format(
        ORDINAL[day_number], gifts)


def verses(start, end):
    return ''.join([verse(n) + '\n'
                    for n in range(start, end + 1)])


def sing():
    return verses(1, 12)

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
trackler-2.2.1.67 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.66 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.65 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.64 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.63 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.62 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.61 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.60 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.59 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.58 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.57 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.56 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.55 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.54 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.53 tracks/python/exercises/twelve-days/example.py