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

import math

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


def consonantCount(s):
    return 42


def rotateStringLeft(s, n):
    return "42"


def isRotation(s, t):
    return False


def mostFrequentLetters(s):
    return "42"


def mostFrequentSubstring(text, n):
    return "42"


def encodeColumnShuffleCipher(message, key):
    return "42"


def decodeColumnShuffleCipher(message):
    return "42"


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


def testConsonantCount():
    print("There are no testcases here, you should write some")


def testRotateStringLeft():
    print("Testing rotateStringLeft()...", end="")
    assert rotateStringLeft("abcde", 0) == "abcde"
    assert rotateStringLeft("abcde", 1) == "bcdea"
    assert rotateStringLeft("abcde", 2) == "cdeab"
    assert rotateStringLeft("abcde", 3) == "deabc"
    assert rotateStringLeft("abcde", 4) == "eabcd"
    assert rotateStringLeft("abcde", 5) == "abcde"
    assert rotateStringLeft("abcde", 25) == "abcde"
    assert rotateStringLeft("abcde", 28) == "deabc"
    assert rotateStringLeft("abcde", -1) == "eabcd"
    assert rotateStringLeft("abcde", -24) == "bcdea"
    assert rotateStringLeft("abcde", -25) == "abcde"
    assert rotateStringLeft("abcde", -26) == "eabcd"
    print("Passed!")


def testIsRotation():
    print("Testing isRotation()...", end="")
    assert isRotation("a", "a") == False  # a string is not a rotation of itself
    assert isRotation("", "") == False  # a string is not a rotation of itself
    assert isRotation("ab", "ba") == True
    assert isRotation("abcd", "dabc") == True
    assert isRotation("abcd", "cdab") == True
    assert isRotation("abcd", "bcda") == True
    assert isRotation("abcd", "abcd") == False
    assert isRotation("abcd", "bcd") == False
    assert isRotation("abcd", "bcdx") == False
    print("Passed!")


def testMostFrequentLetters():
    print("Testing mostFrequentLetters()...", end="")

    s = "We attack at Dawn"
    result = "atwcdekn"
    assert mostFrequentLetters(s) == result

    s = "Note that digits, punctuation, and whitespace are not letters!"
    result = "teanioscdhpruglw"
    assert mostFrequentLetters(s) == result

    s = ""
    result = ""
    assert mostFrequentLetters(s) == result

    print("Passed!")


def testMostFrequentSubstring():
    print("There are no testcases here, you should write some")


def testEncodeColumnShuffleCipher():
    print("Testing encodeColumnShuffleCipher()...", end="")

    msg = "WEATTACKATDAWN"
    result = "1320TKA-WTAWACD-EATN"
    assert encodeColumnShuffleCipher(msg, "1320") == result

    msg = "SUDDENLYAWHITERABBITWITHPINKEYESRANCLOSEBYHER"
    result = "210DNAIRBWHNYRCSYRUEYHEBTTIESNOBESDLWTAIIPKEALEH"
    assert encodeColumnShuffleCipher(msg, "210") == result

    print("Passed!")


def testDecodeColumnShuffleCipher():
    print("Testing decodeColumnShuffleCipher()...", end="")
    msg = "1320TKA-WTAWACD-EATN"
    result = "WEATTACKATDAWN"
    assert decodeColumnShuffleCipher(msg) == result

    msg = "210DNAIRBWHNYRCSYR-UEYHEBTTIESNOBE-SDLWTAIIPKEALEH-"
    result = "SUDDENLYAWHITERABBITWITHPINKEYESRANCLOSEBYHER"
    assert decodeColumnShuffleCipher(msg) == result

    print("Passed!")


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


def testAll():
    # comment out the tests you do not wish to run!
    testConsonantCount()
    testRotateStringLeft()
    testIsRotation()
    testMostFrequentLetters()
    testMostFrequentSubstring()
    testEncodeColumnShuffleCipher()
    testDecodeColumnShuffleCipher()


def main():
    testAll()


if __name__ == "__main__":
    main()
