#################################################
# hw1.py
#
# Your name:
# Your andrew id:
#################################################

import math

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


#### isValidYearOfBirth ####

def isValidYearOfBirth(year):
    return False

#### numberOfPoolBalls ####

def numberOfPoolBalls(rows):
    return 42

#### getTheCents ####

def getTheCents(n):
    return 42

#### isPerfectCube ####

def isPerfectCube(n):
    return False

#### isSymmetricNumber ####

def isSymmetricNumber(n):
    return False

#### circleIntersection ####

def distance(x1, y1, x2, y2):
    return 42.0

def circleIntersection(xa, ya, ra, xb, yb, rb):
    return 0

#### colorBlender ####

def colorBlender(rgb1, rgb2, midpoints, n):
    return 42


#### isValidYearOfBirth ####

def testIsValidYearOfBirth():
    print("Testing isValidYearOfBirth()... ", end="")
    assert(isValidYearOfBirth(2023))
    assert(isValidYearOfBirth(2024) == False)
    assert(isValidYearOfBirth(-1) == False)
    assert(isValidYearOfBirth("2022") == False)
    assert(isValidYearOfBirth(None) == False)
    assert(isValidYearOfBirth(2022.0) == False)
    assert(isValidYearOfBirth(1900) == False)
    assert(isValidYearOfBirth(1910))
    assert(isValidYearOfBirth(2000))
    print("Passed.")


#### numberOfPoolBalls ####

def testNumberOfPoolBalls():
    print('Testing numberOfPoolBalls()... ', end='')
    assert(numberOfPoolBalls(0) == 0)
    assert(numberOfPoolBalls(1) == 1)
    assert(numberOfPoolBalls(2) == 3)   # 1+2 == 3
    assert(numberOfPoolBalls(3) == 6)   # 1+2+3 == 6
    assert(numberOfPoolBalls(10) == 55)  # 1+2+...+10 == 55
    print('Passed.')


#### getTheCents ####

def testGetTheCents():
    print("Testing getTheCents()... ", end="")
    assert(getTheCents(42) == 0)
    assert(getTheCents(42.5) == 50)
    assert(getTheCents(42.50) == 50)
    assert(getTheCents("2022") == 0)
    assert(getTheCents(None) == 0)
    assert(getTheCents(42.42) == 42)
    print("Passed.")


#### isPerfectCube ####

def testIsPerfectCube():
    print('Testing isPerfectCube()... ', end='')
    assert(isPerfectCube(0) == True)
    assert(isPerfectCube(-1) == True)
    assert(isPerfectCube(1) == True)
    assert(isPerfectCube(16) == False)
    assert(isPerfectCube(8) == True)
    assert(isPerfectCube(1234**3) == True)
    assert(isPerfectCube(15) == False)
    assert(isPerfectCube(17) == False)
    assert(isPerfectCube(-16) == False)
    assert(isPerfectCube(-64) == True)
    assert(isPerfectCube(16.0000001) == False)
    assert(isPerfectCube('Do not crash here!') == False)
    print('Passed.')


#### isSymmetricNumber ####

def testIsSymmetricNumber():
    print("Testing isSymmetricNumber()... ", end="")
    assert(isSymmetricNumber(77) == True)
    assert(isSymmetricNumber(1) == False)
    assert(isSymmetricNumber(2020) == True)
    assert(isSymmetricNumber(987987) == True)
    assert(isSymmetricNumber(987789) == False)
    assert(isSymmetricNumber(111) == False)
    assert(isSymmetricNumber(1111) == True)
    assert(isSymmetricNumber(1111.0) == False)
    assert(isSymmetricNumber(-1111) == False)
    print("Passed.")


#### circleIntersection ####

def testDistance():
    print('Testing distance()... ', end='')
    assert(distance(0,0,0,2) == 2)
    assert(distance(2,0,0,0) == 2)
    assert(distance(0,0,0,0) == 0)
    print('Passed.')


def testCircleIntersection():
    print('Testing circleIntersection()... ', end='')
    assert(circleIntersection(0,0,1,1,1,1)==2)
    assert(circleIntersection(1,1,1,1,1,1)==float('inf'))
    assert(circleIntersection(0,0,3,10,10,2)==0)
    print('Passed.')


#### colorBlender ####

def testColorBlender():
    print('Testing colorBlender()... ', end='')
    # http://meyerweb.com/eric/tools/color-blend/#DC143C:BDFCC9:3:rgbd
    assert(colorBlender(220020060, 189252201, 3, -1) is None)
    assert(colorBlender(220020060, 189252201, 3, 0) == 220020060)
    assert(colorBlender(220020060, 189252201, 3, 1) == 212078095)
    assert(colorBlender(220020060, 189252201, 3, 2) == 205136131)
    assert(colorBlender(220020060, 189252201, 3, 3) == 197194166)
    assert(colorBlender(220020060, 189252201, 3, 4) == 189252201)
    assert(colorBlender(220020060, 189252201, 3, 5) is None)
    # http://meyerweb.com/eric/tools/color-blend/#0100FF:FF0280:2:rgbd
    assert(colorBlender(1000255, 255002128, 2, -1) is None)
    assert(colorBlender(1000255, 255002128, 2, 0) == 1000255)
    assert(colorBlender(1000255, 255002128, 2, 1) == 86001213)
    assert(colorBlender(1000255, 255002128, 2, 2) == 170001170)
    assert(colorBlender(1000255, 255002128, 2, 3) == 255002128)
    print('Passed.')


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

def testAll():
    # comment out the tests you do not wish to run!
    testIsValidYearOfBirth()
    testNumberOfPoolBalls()
    testGetTheCents()
    testIsPerfectCube()
    testIsSymmetricNumber()
    testDistance()
    testCircleIntersection()
    testColorBlender()

def main():
    testAll()

if __name__ == '__main__':
    main()
