# Lillian Lee, LJL2, April 2021

"""Quick and dirty code for 2019FA prelim 2 questions."""

import copy # for deepcopy, for making sure inputs aren't changed
import cornellasserts as ca

##################
# Q2(a)

def skipmult(alist, n, k):
    pass

# some testing code
print("Checking skipmult")
testcases = [
    # format: ((input list, input n, input k), what list gets changed to)
    (([1, 3, 5, 7], 2, 2 ), [2, 3, 10, 7]),
    (([1, 3, 5, 7], 2, 3), [2, 3, 5, 14]),
    ]

for item in testcases:
    theinput = item[0]
    inlist = theinput[0]
    n = theinput[1]
    k = theinput[2]    

    correct_change = item[1]
    error_msg_start = "skipmult problem " # prepare for any errors
    error_msg_start += "on input " + str(repr(theinput)) + ": "

    result = skipmult(inlist, n, k)
    
    # shouldn't return anything
    assert result is None, \
        error_msg_start + "should return None, but returned " + repr(result)

    # check values are correct
    assert inlist == correct_change, \
        error_msg_start + "expected the list to become " + repr(correct_change) \
        + " but it became/stayed " + repr(inlist)
print("Checking skipmult finished")


##################
# Q2(b)

def merge(dict1,dict2):
    pass

# some testing code
print("Checking merge")
ca.assert_equals({'a':1,'b':5,'c':4}, merge({'a':1,'b':2},{'b':3,'c':4}))

print("Checking merge finished")

##################
# Q3(a)

def clamp(thelist, m1, m2):

# some testing code
print("Checking clamp")
testcases = {((-1, 1, 3, 5), 0, 4): [0, 1, 3, 4],
             ((1, 3), 0, 4): [1,3],
             ((-1, 1, 3, 5), 1, 1): [1, 1, 1, 1],
             ((5, 0, 2, 7, 4), 0, 4.5):[4.5, 0, 2, 4.5, 4],
             ((5, 0, 1, 7, 4), 0.5, 4): [4, 0.5, 1, 4, 4],
             ((), 0, 4): []
             }

for tc in testcases:
    thelist = list(tc[0])
    m1 = tc[1]
    m2 = tc[2]
    expected = testcases[tc]

    error_msg_start = "clamp problem " # prepare for any errors
    error_msg_start += "on input " + str(repr(tc)) + ": "

    result = clamp(thelist, m1, m2)
    assert expected == result , error_msg_start + \
        "expecting " + str(expected) + " but got " + str(result)

print("Checking clamp finished")


##################
# Q3(b)

def disemvowel(text):
    pass

# some testing code
print("Checking disemvowel")
testanswers= {
    'membership':  ('mmbrshp','eei'),
    'grr': ('grr', ''),
    'aie': ('', 'aie'),
    '': ('', '')
}


for s in testanswers:
    error_msg_start = "disemvowel problem " # prepare for any errors
    error_msg_start += "on input " + str(s) + ": " 
    result = disemvowel(s)
    assert result == testanswers[s], \
        error_msg_start + "expected output " + repr(testanswers[s]) \
        + " but got " + repr(result)



print("Checking disemvowel")
