import cs112_m20_day2_linter
import math

#################################################
# Helper functions
#################################################

def almostEqual(d1, d2, epsilon=10**-7):
    return (abs(d2 - d1) < epsilon)

import decimal
def roundHalfUp(d):
    # Round to nearest with ties going away from zero.
    rounding = decimal.ROUND_HALF_UP
    # See other rounding options here:
    # https://docs.python.org/3/library/decimal.html#rounding-modes
    return int(decimal.Decimal(d).to_integral_value(rounding=rounding))

#################################################
# Additional functions that are given
#################################################

def isPrime(n):
    if (n < 2):
        return False
    if (n == 2):
        return True
    if (n % 2 == 0):
        return False
    maxFactor = roundHalfUp(n**0.5)
    for factor in range(3,maxFactor+1,2):
        if (n % factor == 0):
            return False
    return True

def digitCount(n):
    count = 0
    while n > 0:
        count += 1
        n //= 10
    return count

def rotateNumber(n):
    onesPlace = n % 10
    n //= 10
    return onesPlace*10**digitCount(n) + n

#################################################
# Functions for you to write
#################################################

def isCircularPrime(n):
    return 42


#################################################
# Test Functions
################################################


def testIsCircularPrime():
    print('Testing isCircularPrime()... ', end='')
    assert(isCircularPrime(2) == True)
    assert(isCircularPrime(11) == True)
    assert(isCircularPrime(13) == True)
    assert(isCircularPrime(79) == True)
    assert(isCircularPrime(197) == True)
    assert(isCircularPrime(1193) == True)
    assert(isCircularPrime(42) == False)
    print('Passed!')

#################################################
# Main
################################################

def testAll():
    testIsCircularPrime()

def main():
    cs112_m20_day2_linter.lint()
    testAll()

if __name__ == '__main__':
    main()
