The reflection of letter
The letter
The Narcissus cipher encodes a message by replacing each letter
with its reflection at distance
One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Fourteen, Fifteen!
is for example encoded as
NPmodf, RVuymq, QWekoubhbh, BJksqynv, AKdnqazj, MYcord, LZxlocxlgu, WMaqyozplb, EWzrewvn, JDuodx, TPawtpkgtpcy, HFkisqzxjhsq, GGuuvveeggrrrraa, RTacgidffhqsqszb, QUtxqueiptptyc!
where the word One is encoded with distance
Write a function jump that takes two arguments: i)
a character
Write a function reflection that takes two arguments: i)
a character
Write a function fixation that takes two arguments: i)
a letter pair
Write a function encode that takes a plaintext1 (str) and returns the corresponding ciphertext2 (str) according to the Narcissus cipher.
Write a function decode that takes a ciphertext3 that is supposed to be encoded
according to the Narcissus cipher, and returns the corresponding plaintext4 (str). If the given
ciphertext could not have resulted from encoding a plaintext according
to the Narcissus cipher, the function must raise an AssertionError
with message invalid pair:
>>> jump('V', 7)
'C'
>>> jump('v', -7)
'o'
>>> jump('!', 13)
Traceback (most recent call last):
AssertionError: invalid letter: !
>>> reflection('V', 1)
'UW'
>>> reflection('v', 7)
'oc'
>>> reflection('!', 13)
Traceback (most recent call last):
AssertionError: invalid letter: !
>>> fixation('UW', 1)
'V'
>>> fixation('oc', 7)
'v'
>>> fixation('cm', 4)
Traceback (most recent call last):
AssertionError: invalid pair: cm
>>> encode('One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Fourteen, Fifteen!')
'NPmodf, RVuymq, QWekoubhbh, BJksqynv, AKdnqazj, MYcord, LZxlocxlgu, WMaqyozplb, EWzrewvn, JDuodx, TPawtpkgtpcy, HFkisqzxjhsq, GGuuvveeggrrrraa, RTacgidffhqsqszb, QUtxqueiptptyc!'
>>> encode('And Now for Something Completely Different')
'ZBmoce LPmquy cilrou OWksiqaipxdlemjrck XHjthrkugqzjoyzjgqtd XJcozlzlyklxykhtnz'
>>> decode('NPmodf, RVuymq, QWekoubhbh, BJksqynv, AKdnqazj, MYcord, LZxlocxlgu, WMaqyozplb, EWzrewvn, JDuodx, TPawtpkgtpcy, HFkisqzxjhsq, GGuuvveeggrrrraa, RTacgidffhqsqszb, QUtxqueiptptyc!')
'One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Fourteen, Fifteen!'
>>> decode('ZBmoce LPmquy cilrou OWksiqaipxdlemjrcm XHjthrkugqzjoyzjgqtd XJcozlzlyklxykhtnz')
Traceback (most recent call last):
AssertionError: invalid pair: cm
Nárkissos (Ancient Greek: Νάρκισσος) or Narcissus (Latin) is a character from Greek mythology. He was a son of the river god Cephissus5 and the nymph Liriope6. The most popular account of Narcissus is by Ovid7, who passed on the Greek myth as a poem in Latin (Metamorphoses 3.341-510). Ovid's version tells the story from the metamorphosis of the nymph Echo to the metamorphosis of Narcissus.
Narcissus was a hunter from Thespiae8 in Boeotia9 who was known for his beauty. He rejected all romantic advances, eventually falling in love with his own reflection in a pool of water, staring at it for the remainder of his life. After he died, in his place sprouted a flower bearing his name.
The character of Narcissus is the origin of the term narcissism10, a fixation with oneself.