#################################################
# hw6.py
#################################################

def colCount(L, col, value):
    return 42

def getScattergoriesScores(L):
    return 42

def getScattergoriesWinners(L):
    return 42

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

def isLatinSquare(L):
    return 42

def isKnightsTour(board):
    return 42

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

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

def testColCount():
    print('Testing colCount()...', end='')
    assert(colCount([ [1, 2, 3] ], 2, 3) == 1)
    assert(colCount([ [1, 2, 3], [3, 2, 1] ], 2, 3) == 1)
    assert(colCount([ [1, 2, 3], [3, 2, 1], [3, 3, 3] ], 2, 3) == 2)
    assert(colCount([ [1, 2, 3], [3, 2, 3], [1, 2, 3] ], 2, 3) == 3)
    assert(colCount([ [1, 2, 3] ], 2, 2) == 0)
    assert(colCount([ [1, 2, 3] ], 4, 3) == 0)
    print('Passed')

def testGetScattergoriesScores():
    print('Testing getScattergoriesScores()...', end='')
    assert(getScattergoriesScores([
            [ 'Player', 'Dog breed', 'City',    'Color', ],
            [ 'John',   'bulldog',   'boston',  'beige'  ],
            [ 'Joan',   'basset',    'berlin',  'brown'  ],
            [ 'Jane',   'basset',    'boston',  'brown'  ],
            [ 'Jan',    'beagle',    'bruges',  'blue'   ]
        ]) == [
            [ 'John', 2 ],
            [ 'Joan', 1 ],
            [ 'Jane', 0 ],
            [ 'Jan',  3 ]
        ])
    print('Passed!')

def testGetScattergoriesWinners():
    print('Testing getScattergoriesWinners()...', end='')
    assert(getScattergoriesWinners([
            [ 'Player', 'Dog breed', 'City',    'Color', ],
            [ 'John',   'bulldog',   'boston',  'beige'  ],
            [ 'Joan',   'basset',    'berlin',  'brown'  ],
            [ 'Jane',   'basset',    'boston',  'brown'  ],
            [ 'Jan',    'beagle',    'bruges',  'blue'   ]
        ]) == [ 'Jan' ])
    assert(getScattergoriesWinners([
            [ 'Player', 'Dog breed', 'City',    'Color', ],
            [ 'John',   'bulldog',   'boston',  'beige'  ],
            [ 'Joan',   'basset',    'berlin',  'brown'  ],
            [ 'Jane',   'basset',    'boston',  'brown'  ],
            [ 'Jan',    'beagle',    'berlin',  'blue'   ]
        ]) == [ 'Jan', 'John' ])
    print('Passed')

def testBonusIsLatinSquare():
    print('Testing bonus isLatinSquare()...', end='')
    assert isLatinSquare([[1,2,3],[2,3,1],[3,1,2]])==True
    assert isLatinSquare([[1,2,3,4,5],[2,3,5,1,4],[3,5,4,2,1],
                         [4,1,2,5,3],[5,4,1,3,2]])==True
    assert isLatinSquare([[1,2,3],[2,3,1],[3,1,5]])==False
    assert isLatinSquare([[1,2,3,4,5],[2,3,6,1,4],[3,5,4,2,1],
                         [4,1,2,5,3],[5,4,1,3,2]])==False
    assert isLatinSquare([[2,7,6],[9,5,1]])==False
    assert isLatinSquare([[2,7,6],[9,5,1],[4,3,9]])==False
    print('Passed!')

def testBonusIsKnightsTour():
    print('Testing bonus isKnightsTour()...', end='')
    L = [ [ 38, 41, 18,  3, 22, 27, 16,  1],
          [ 19,  4, 39, 42, 17,  2, 23, 26],
          [ 40, 37, 54, 21, 52, 25, 28, 15],
          [  5, 20, 43, 56, 59, 30, 51, 24],
          [ 36, 55, 58, 53, 44, 63, 14, 29],
          [  9,  6, 45, 62, 57, 60, 31, 50],
          [ 46, 35,  8, 11, 48, 33, 64, 13],
          [  7, 10, 47, 34, 61, 12, 49, 32]
        ]
    assert(isKnightsTour(L) == True)
    L = [ [ 38, 41, 18,  3, 22, 27, 16,  1],
          [ 19,  4, 39, 42, 17,  2, 23, 26],
          [ 40, 37, 54, 21, 52, 25, 28, 15],
          [  5, 20, 43, 56, 59, 30, 51, 24],
          [ 36, 55, 58, 53, 44, 64, 14, 29],
          [  9,  6, 45, 62, 57, 60, 31, 50],
          [ 46, 35,  8, 11, 48, 33, 64, 13],
          [  7, 10, 47, 34, 61, 12, 49, 32]
        ]
    assert(isKnightsTour(L) == False)
    L = [ [ 38, 41, 18,  3, 22, 27, 16,  0],
          [ 19,  4, 39, 42, 17,  2, 23, 26],
          [ 40, 37, 54, 21, 52, 25, 28, 15],
          [  5, 20, 43, 56, 59, 30, 51, 24],
          [ 36, 55, 58, 53, 44, 63, 14, 29],
          [  9,  6, 45, 62, 57, 60, 31, 50],
          [ 46, 35,  8, 11, 48, 33, 64, 13],
          [  7, 10, 47, 34, 61, 12, 49, 32]
        ]
    assert(isKnightsTour(L) == False)
    L = [ [  8, 11, 6,  3],
          [  1,  4, 9, 12],
          [ 10,  7, 2,  5]
        ]
    assert(isKnightsTour(L) == True)
    print('Passed!')

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

def testAll():
    testColCount()
    testGetScattergoriesScores()
    testGetScattergoriesWinners()
    #testBonusIsLatinSquare()
    #testBonusIsKnightsTour()

if __name__ == '__main__':
    testAll()
