Part 1: CTs and Fill-In-The-Blank

You may not run any code in Part 1. Once you move to Part 2, you may not return to Part 1.

Note: The Free Response Previews are previews of the question you must solve in Part 2, so that you can choose when to move on from Part 1. You will be able to run code in the testing environment in Part 2. Remember, you will not be able to return to Part 1 once you have moved to Part 2.

CT1: Code Tracing [30 pts]

Indicate what the following code prints. Place your answers (and nothing else) in the box below. Note that you may not run this code.

import copy
def f(a):
    return 10*a[0][0]+a[1][0]

def ct1(a):
    b = copy.copy(a)
    c = copy.deepcopy(a)
    d = a
    e = a[0:len(a)]
    c[0][0] = 1
    d[0] = [2]
    e[1] = [3]
    b[0][0] = 4
    print(f(b),f(c),f(d),f(e)) #f is defined above

a= [[5],[6]]
ct1(a)
print(f(a))# don't miss this

Fill-In-The-Blank: wordSearchFromCell(board, word, startRow, startCol) [15 pts]

You are provided with a near-complete solution to wordSearchFromCell, a helper function from the wordSearch case study. Fill in the blanks so that this function works properly.

def wordSearchFromCell(board, word, startRow, startCol):
    for ______________:
        for ______________:
            if ______________:
                result = wordSearchFromCellInDirection(board, word,
                                                    startRow, startCol,
                                                    drow, dcol)
                if (result == True):
                    return result
    return False

Part 2: FR

columnWithLargestSum(L) [55 pts]

Write the function columnWithLargestSum(L) that takes a non-empty, rectangular 2d list L of integers and returns the column (as a list of numbers from top to bottom) with the largest sum. If there is a tie, return the leftmost such column.

For example, given the following list,

[[1, 2, 3],
 [4, 5, 6]]
[3, 6] has the largest sum between the three columns [1, 4], [2, 5], and [3, 6]. So we would return the list [3, 6].

Note: cmu_cs3_utils is not available to you within this environment.

def columnWithLargestSum(L):
    return 42

def testColumnWithLargestSum():
    print('Testing columnWithLargestSum...', end='')

    L = [[1, 2, 3],
         [4, 5, 6]]
    assert(columnWithLargestSum(L) == [3, 6])

    L = [[1, 2, 3],
         [6, 5, 4]]
    assert(columnWithLargestSum(L) == [1, 6])

    L = [[1,  2,  -3],
         [-6, -5, 4],
         [3,  2,  -2]]
    assert(columnWithLargestSum(L) == [2, -5, 2])

    print('Passed!')

testColumnWithLargestSum()