Ejemplo n.º 1
0
def make_decrypter(f1, f2, f3):
    """Generates a "decrypter" function.

    >>> brutus3 = caesar_generator(3, sub)
    >>> brutus2 = caesar_generator(2, sub)
    >>> decrypter = make_decrypter(brutus2, mirror_letter, brutus3)
    >>> decrypter('yxwv') # brutus3(mirror_letter(brutus2('y'))) = 'a'
    'abcd'
    """
    f1, f2, f3 = looper(f1), looper(f2), looper(f3)
    return lambda cs: f3(f2(f1(cs)))
Ejemplo n.º 2
0
def make_encrypter(f1, f2, f3):
    """Generates an "encrypter" that applies a specific set of encryption
    functions on the message

    >>> caesar3 = caesar_generator(3, add)
    >>> caesar2 = caesar_generator(2, add)
    >>> encrypter = make_encrypter(caesar2, mirror_letter, caesar3)
    >>> encrypter('abcd') # caesar2(mirror_letter(caesar3('a'))) -> 'y'
    'yxwv'
    """
    f1, f2, f3 = looper(f1), looper(f2), looper(f3)
    return lambda ucs: f1(f2(f3(ucs)))
Ejemplo n.º 3
0
def make_decrypter(f1, f2, f3):
    """Generates a "decrypter" function.

    >>> brutus3 = caesar_generator(3, sub)
    >>> brutus2 = caesar_generator(2, sub)
    >>> decrypter = make_decrypter(brutus2, mirror_letter, brutus3)
    >>> decrypter('yxwv') # brutus3(mirror_letter(brutus2('y'))) = 'a'
    'abcd'
    """
    f1, f2, f3 = looper(f1), looper(f2), looper(f3)
    "*** YOUR CODE HERE ***"
    return lambda word: f3(f2(f1(word)))
Ejemplo n.º 4
0
def make_decrypter(f1, f2, f3):
    """Generates a "decrypter" function.

    >>> brutus3 = caesar_generator(3, sub)
    >>> brutus2 = caesar_generator(2, sub)
    >>> decrypter = make_decrypter(brutus2, mirror_letter, brutus3)
    >>> decrypter('yxwv') # brutus3(mirror_letter(brutus2('y'))) = 'a'
    'abcd'
    """
    f1, f2, f3 = looper(f1), looper(f2), looper(f3)
    def decry(message):
        return f3(f2(f1(message)))
    return decry
Ejemplo n.º 5
0
def make_encrypter(f1, f2, f3):
    """Generates an "encrypter" that applies a specific set of encryption
    functions on the message

    >>> caesar3 = caesar_generator(3, add)
    >>> caesar2 = caesar_generator(2, add)
    >>> encrypter = make_encrypter(caesar2, mirror_letter, caesar3)
    >>> encrypter('abcd') # caesar2(mirror_letter(caesar3('a'))) -> 'y'
    'yxwv'
    """
    f1, f2, f3 = looper(f1), looper(f2), looper(f3)
    "*** YOUR CODE HERE ***"
    return lambda word: f1(f2(f3(word)))
Ejemplo n.º 6
0
def make_encrypter(f1, f2, f3):
    """Generates an "encrypter" that applies a specific set of encryption
    functions on the message

    >>> caesar3 = caesar_generator(3, add)
    >>> caesar2 = caesar_generator(2, add)
    >>> encrypter = make_encrypter(caesar2, mirror_letter, caesar3)
    >>> encrypter('abcd') # caesar2(mirror_letter(caesar3('a'))) -> 'y'
    'yxwv'
    """
    f1, f2, f3 = looper(f1), looper(f2), looper(f3)
    def encry(message):
        return f1(f2(f3(message)))
    return encry
Ejemplo n.º 7
0
def make_decrypter(f1, f2, f3):
    """Generates a "decrypter" function.

    >>> brutus3 = caesar_generator(3, sub)
    >>> brutus2 = caesar_generator(2, sub)
    >>> decrypter = make_decrypter(brutus2, mirror_letter, brutus3)
    >>> decrypter('yxwv') # brutus3(mirror_letter(brutus2('y'))) = 'a'
    'abcd'
    """
    f1, f2, f3 = looper(f1), looper(f2), looper(f3)
    "*** YOUR CODE HERE ***"

    def decrypter(x):
        return f3(f2(f1(x)))

    return decrypter