'''
Created on Dec 6, 2016

@author: Nicolette Hevizi
'''
import random
def builddict(items):
    '''
    items is a list of items, builddict randomly shuffles and selects 12 
    then returns a dictionary with number 1-12 (key) and corresponding item and order (value)
    '''
    d= {}
    random.shuffle(items)
    gifts= items[:12]
    nums= ['1','2','3','4','5','6','7','8','9','10','11','12']
    
    for (num,gift) in zip(nums,gifts):
        suffix= ""
        ending= ""
        if num == '1':
            suffix= "st"
        if num == '2':
            suffix= "nd"
            ending= "s"
        if num == '3':
            suffix= "rd"
            ending= "s"
        elif num in ['4','5','6','7','8','9','10','11','12']:
            suffix= "th"
            ending= "s"
        d[num]=[num+suffix, gift+ending]
    return d
    
def twelvedays(name, items):
    '''
    using the dictionary built with builddict, prints out song verses
    '''
    
    d= builddict(items)
    alist= [(k,v[0],v[1]) for (k,v) in d.items()]
    blist= [(int(num),day, gift) for (num, day, gift) in alist]
    clist= sorted(blist)
    
    numlist= [x for (x,y,z) in clist]
    daylist= [y for (x,y,z) in clist]
    giftlist= [z for (x,y,z) in clist]

    for n in range(12):
        print "On the" ,daylist[n], "day of", name, "my true love gave to me"
        while True:
            if n < 0:
                break
            print numlist[n], giftlist[n]
            n= n-1
        print

if __name__ == '__main__':
    print "The APT due date is approaching... and so are the holidays" 
    print "but the green and red on the APT page indicates failure instead of holiday cheer"
    print "Praying a Christmas miracle will turn these APTs evergreen..."
    print "and when the APTs are all green, there is nothing left to do but celebrate and sing"
    print 
    print '12 DAYS OF COMPSCI CAROL'
    print "may your days be merry and bright, and may all your APTs be green :)"
    print
    compsci= ['all green APT', 'algorithm', 'assignment', 'dictionary', 'function', 'lab', 'list comprehension', 'piazza question', 'python reference sheet', 'reading quiz', 'regular expression', 'tuple', '"while" loop', '"for" loop']
    twelvedays("CompSci" , compsci)
    print
    print
    print '12 DAYS OF CROSSFIT: Christmas Workout Generator'
    print 'every year, CrossFit gyms have a holiday themed workout'
    print 'that uses the format of the 12 days of christmas song.'
    print 'The function "twelvedays" can be used to generate' 
    print 'a unique version of this workout each time.' 
    print
    crossfit= ['muscleup','ringdip','handstand pushup','toes-to-bar', 'pullup', 'clean','snatch','shoulder to overhead', 'thruster', 'overhead squat', 'box jump', 'burpee', 'rowing machine calorie', 'double under', 'wall ball', 'kettlebell swing','deadlift','pistol squat','sumo deadlift high pull', 'turkish getup', 'rope climb', 'GHD situps']
    twelvedays("CrossFit" , crossfit)
