# Allison Obourn
# CSC 110, Spring 2018
# Lecture 30

# Demonstrates manipulation and creation of lists of
# lists

def main():
    data = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
    flip(data, 2, 3)
    lis = create_matrix2(5, 3)
    print(lis)
    lis[0][0] = 42
    print(lis)

# creates and returns a width by height matrix
# each row contains numbers starting at 0 and
# coutning up by 1s
def create_matrix2(width, height):
    # create matrix filled with 0s
    lis = []
    for i in range(height):
        lis.append([0] * width)

    # fill created matrix    
    for i in range(height):
        inner = lis[i]
        for j in range(width):
            inner[j] = j
    return lis    

# creates and returns a width by height matrix
# each row contains numbers starting at 0 and
# coutning up by 1s
def create_matrix(width, height):
    lis = []
    for i in range(height):
        inner = []
        lis.append(inner)
        for j in range(width):
            inner.append(j)
    return lis
    
# takes a list of lists and two column numbers as
# parameters and swaps those columns in the passed
# in list of lists
def flip(data, c1, c2):
    for i in range(len(data)):
        temp = data[i][c1 - 1]
        data[i][c1 - 1] = data[i][c2 - 1]
        data[i][c2 - 1] = temp
        

main()
