import string


def decode_text(text, cipher):
    """Decodes given text with substitution cipher 
    
    Parameters
    ----------
    text : string
    cipher : np.array() of size 26, permutation  
    
    Returns
    ----------
    decoded_text : string 
    """
    new_text = ''
    alphabet = string.ascii_lowercase
    Alphabet = string.ascii_uppercase
    for char in text:
        if ord('A') <= ord(char) <= ord('Z'):
                i = ord(char) - ord('A') 
                new_text += Alphabet[cipher[i]%26] # uppercase letters are substituted with decoded letter
        elif ord('a') <= ord(char) <= ord('z'):
                i = ord(char) - ord('a')
                new_text += alphabet[cipher[i]%26]  # lowercase letters are substituted with decoded letter
        else:
            new_text += char  # non-letter characters are added without modification
    return new_text