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

import math

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


#### isValidYearOfBirth ####

def isValidYearOfBirth(year):
    return False

#### getTheCents ####

def getTheCents(n):
    return 0

#### getKthDigit ####

def getKthDigit(n, k):
    return 0

#### setKthDigit ####

def setKthDigit(n, k, d=0):
    return n

#### circleIntersection ####

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

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

#### colorHarmony ####

def angleToRGB(h):
    return 42

def rgbToAngle(rgb):
    return 42

def colorHarmony(color1, color2):
    return 42

#### isValidYearOfBirth ####

def testIsValidYearOfBirth():
    print("Testing isValidYearOfBirth()... ", end="")
    assert(isValidYearOfBirth(2023) == True)
    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) == True)
    assert(isValidYearOfBirth(2000) == True)
    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.1") == 0)
    assert(getTheCents(None) == 0)
    assert(getTheCents(42.42) == 42)
    print("Passed.")


#### getKthDigit ####

def testGetKthDigit():
    print('Testing getKthDigit()... ', end='')
    assert(getKthDigit(809, 0) == 9)
    assert(getKthDigit(809, 1) == 0)
    assert(getKthDigit(809, 2) == 8)
    assert(getKthDigit(809, 3) == 0)
    assert(getKthDigit(0, 100) == 0)
    assert(getKthDigit(-809, 0) == 9)
    print('Passed.')


#### setKthDigit ####

def testSetKthDigit():
    print('Testing setKthDigit()... ', end='')
    assert(setKthDigit(809, 0, 7) == 807)
    assert(setKthDigit(809, 1, 7) == 879)
    assert(setKthDigit(809, 2, 7) == 709)
    assert(setKthDigit(809, 3, 7) == 7809)
    assert(setKthDigit(0, 4, 7) == 70000)
    assert(setKthDigit(-809, 0, 7) == -807)
    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)
    print(circleIntersection(1,1,1,1,1,1))
    assert(circleIntersection(1,1,1,1,1,1)==float('inf'))
    assert(circleIntersection(0,0,3,10,10,2)==0)
    print('Passed.')


#### colorHarmony ####

def testRGBToAngle():
    print("Testing rgbToAngle()...", end="")
    assert(rgbToAngle(255000000)==0) # red
    assert(rgbToAngle(255128000)== 30) # orange
    assert(rgbToAngle(255234010)== None) # invalid: not at the perimeter
    print("Passed. (Add more tests to be more sure!)")


def testAngleToRGB():
    print("Testing ()...", end="")
    assert(angleToRGB(0)==255000000) #red
    assert(angleToRGB(360)==255000000) # same red
    assert(angleToRGB(0.2)==255001000) # very close to red
    assert(angleToRGB(30)==255128000) # orange
    print("Passed. (Add more tests to be more sure!)")

def testColorHarmony():
    print("Testing colorHarmony()...", end="")
    assert(colorHarmony(255038000,255034)==36000255)
    assert(colorHarmony(128255000,128000255)==255255)
    assert(colorHarmony(255255000,255000)==128000255)
    assert(colorHarmony(255128000,255128)==128000255)
    print("Passed. (Add more tests to be more sure!)")

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

def testAll():
    # comment out the tests you do not wish to run!
    testIsValidYearOfBirth()
    testGetTheCents()
    testGetKthDigit()
    testSetKthDigit()
    testDistance()
    testCircleIntersection()
    testColorHarmony()

def main():
    testAll()

if __name__ == '__main__':
    main()
