#################################################
# hw7.py
#################################################

def valuesInCol(L, c):
    return 42

def colHasDuplicateValues(L, c):
    return 42

def valueCountsInCol(L, c):
    return 42

def mostFrequentValueInCol(L, c):
    return 42

def namesOfTwentySomethings(people):
    return 42

######################################################################
# bonus/optional: you can ignore the functions below here
######################################################################

######################################################################
# ignore_rest: The autograder will ignore all code below here
######################################################################

#################################################
# Test Functions
#################################################

class Struct(object):
    pass

def testValuesInCol():
    print('Testing valuesInCol()...', end='')
    L = [ [ 'dog', 'cat', 'cow' ],
          [ 'cat', 'fox', 'cow' ],
          [ 'dog', 'elk', 'pig' ],
          [ 'cub', 'bat', 'pig' ] ]
    assert(valuesInCol(L, -1) == None)
    assert(valuesInCol(L, 0) == { 'dog', 'cat', 'cub' })
    assert(valuesInCol(L, 1) == { 'cat', 'fox', 'elk', 'bat' } )
    assert(valuesInCol(L, 2) == { 'cow', 'pig' } )
    assert(valuesInCol(L, 3) == None)
    print('Passed!')

def testColHasDuplicateValues():
    print('Testing colHasDuplicateValues()...', end='')
    L = [ [ 'dog', 'cat', 'cow' ],
          [ 'cat', 'fox', 'cow' ],
          [ 'dog', 'elk', 'pig' ],
          [ 'cub', 'bat', 'pig' ] ]
    assert(colHasDuplicateValues(L, 0) == True)
    assert(colHasDuplicateValues(L, 1) == False)
    assert(colHasDuplicateValues(L, 2) == True)
    assert(colHasDuplicateValues(L, 3) == None)
    print('Passed!')

def testValueCountsInCol():
    print('Testing valueCountsInCol()...', end='')
    L = [ [ 'dog', 'cat', 'cow' ],
          [ 'cat', 'fox', 'cow' ],
          [ 'dog', 'elk', 'pig' ],
          [ 'cub', 'bat', 'pig' ] ]
    assert(valueCountsInCol(L, -1) == None)
    assert(valueCountsInCol(L, 0) == { 'dog':2, 'cat':1, 'cub':1 })
    assert(valueCountsInCol(L, 1) == { 'cat':1, 'fox':1, 'elk':1, 'bat':1 } )
    assert(valueCountsInCol(L, 2) == { 'cow':2, 'pig':2 } )
    assert(valueCountsInCol(L, 3) == None)
    print('Passed!')

def testMostFrequentValueInCol():
    print('Testing mostFrequentValueInCol()...', end='')
    L = [ [ 'dog', 'cat', 'cow' ],
          [ 'cat', 'fox', 'cow' ],
          [ 'dog', 'elk', 'pig' ],
          [' cub', 'bat', 'pig' ] ]
    assert(mostFrequentValueInCol(L, 0) == 'dog')
    assert(mostFrequentValueInCol(L, 1) == ['bat', 'cat', 'elk', 'fox'])
    assert(mostFrequentValueInCol(L, 2) == ['cow', 'pig'])
    assert(mostFrequentValueInCol(L, 3) == None)
    # Include these two to test if code depends on order of values in a set
    assert(mostFrequentValueInCol([[1], [1], [0]], 0) == 1)
    assert(mostFrequentValueInCol([[0], [1], [1]], 0) == 1)
    print('Passed!')

def testNamesOfTwentySomethings():
    print('Testing namesOfTwentySomethings()...', end='')
    person1 = Struct()
    person1.name = 'wilma'
    person1.age = 25

    person2 = Struct()
    person2.name = 'betty'
    person2.age = 35

    person3 = Struct()
    person3.name = 'fred'
    person3.age = 28

    person4 = Struct()
    person4.name = 'barney'
    person4.age = 31

    person5 = Struct()
    person5.name = 'fred'
    person5.age = 22

    people = [ person1, person2, person3, person4, person5 ]

    assert(namesOfTwentySomethings(people) == ['fred', 'wilma'])
    print('Passed')

#################################################
# testAll and main
#################################################

def testAll():
    testValuesInCol()
    testColHasDuplicateValues()
    testValueCountsInCol()
    testMostFrequentValueInCol()
    testNamesOfTwentySomethings()

if __name__ == '__main__':
    testAll()
