def split_substrings(ciphertext, keylength):
    """ Splits the ciphertext into 'keylength' substrings and offsets
    them as described in Homework 2 problem 2 """

    substring_list = [''] * keylength
    substring_index = 0
    offset = 0

    # split the ciphertext into substrings
    for letter in ciphertext:
        # offset the letter by which key iteration it is on
        new_letter_value = ord(letter) - offset

        # Can't use modulo, so put it back in range 65-90
        while new_letter_value < 65:
            new_letter_value += 26

        # add it to the list, continue
        substring_list[substring_index] += chr(new_letter_value)
        substring_index += 1
        # If we've gone past the keylength, reset to 0 and increase offset
        if substring_index == keylength:
            substring_index = 0
            offset += 1

    return substring_list