#############################
# hw4.py (PART B)
#
# Your name:
# Your andrew id:
#################################################

import math
import string


#################################################
# Functions (for you to write)
#################################################


#### lookAndSay ####

def lookAndSay(a):
    return []

#### inverseLookAndSay ####

def inverseLookAndSay(a):
    return []

#### maxProfit ####

def maxProfit(prices):
    return 42

#################################################
# Test Functions
#################################################
#### lookAndSay ####

import copy


def _verifyLookAndSayIsNondestructive():
    a = [1, 2, 3]
    b = copy.copy(a)
    lookAndSay(a)  # ignore result, just checking for destructiveness here
    return (a == b)


def testLookAndSay():
    print("Testing lookAndSay()...", end="")
    assert(_verifyLookAndSayIsNondestructive())
    assert(lookAndSay([]) == [])
    assert(lookAndSay([1, 1, 1]) == [(3, 1)])
    assert(lookAndSay([-1, 2, 7]) == [(1, -1), (1, 2), (1, 7)])
    assert(lookAndSay([3, 3, 8, -10, -10, -10]) == [(2, 3), (1, 8), (3, -10)])
    assert(lookAndSay([2] * 5 + [5] * 2) == [(5, 2), (2, 5)])
    assert(lookAndSay([5] * 2 + [2] * 5) == [(2, 5), (5, 2)])
    print("Passed!")


#### inverseLookAndSay ####

import copy


def _verifyInverseLookAndSayIsNondestructive():
    a = [(1, 2), (2, 3)]
    b = copy.copy(a)
    # ignore result, just checking for destructiveness here
    inverseLookAndSay(a)
    return (a == b)


def testInverseLookAndSay():
    print("Testing inverseLookAndSay()...", end="")
    assert(_verifyInverseLookAndSayIsNondestructive())
    assert(inverseLookAndSay([]) == [])
    assert(inverseLookAndSay([(3, 1)]) == [1, 1, 1])
    assert(inverseLookAndSay([(1, -1), (1, 2), (1, 7)]) == [-1, 2, 7])
    assert(inverseLookAndSay([(2, 3), (1, 8), (3, -10)])
           == [3, 3, 8, -10, -10, -10])
    assert(inverseLookAndSay([(5, 2), (2, 5)]) == [2] * 5 + [5] * 2)
    assert(inverseLookAndSay([(2, 5), (5, 2)]) == [5] * 2 + [2] * 5)
    print("Passed!")

#### maxProfit ####

def testMaxProfit():
    print("Testing maxProfit()...", end="")
    print('Failed. This testcode needs to be written by you.')


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

def testAll():
    # comment out the tests you do not wish to run!
    testLookAndSay()
    testInverseLookAndSay()
    testMaxProfit()

def main():
    testAll()

if __name__ == '__main__':
    main()
