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.107 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.106 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.105 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.104 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.103 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.102 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.101 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.100 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.99 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.98 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.97 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.96 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.95 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.94 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.93 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.92 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.91 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.90 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.89 tracks/python/exercises/twelve-days/example.py
trackler-2.2.1.88 tracks/python/exercises/twelve-days/example.py