Rotation is a weak form of encryption that consists of rotating every letter of a word. Rotating a letter is as much as shifting that letter over a set number of positions $$r \in \mathbb{N}$$ in the alphabet. If $$r > 0$$, this is a rotation to the right, and for $$r < 0$$ this is a rotation to the left. Here, the alphabet is seen as a circular list, which comes down to the fact that after the letter z, the letter a follows (when rotating to the right) and that the letter a is thus preceded by the letter z (when rotating to the left).

The rotation of the word monty over three positions gives the word prqwb. Here you can see for example that three positions of the letter m in the alphabet, is the letter p, and that by seeing this rotation as a circular movement, the letter b is three position right of the letter y. Two words are called rotated words if a $$r$$-rotation ($$r \in \mathbb{N}$$) consists that converts the first word in the second word. This way, cobra and freud are examples of rotated words, because a 3-rotation of the word cobra results in the word freud. Note that also a (-3)-rotation or a 23-rotation or the word freud results in the word cobra. The property of rotated words is, in other words, symmetrical.

Assignment

For this assignment, we only work with words that consist solely of lowercase letters. Your assignment is to find the rotated words in a list of words. To do so, you work as follows:

Example

>>> rotation('hal', 1)
'ibm'
>>> rotation('monty', 3)
'prqwb'
>>> rotation('python', 33)
'wfaovu'
>>> rotation('shrubbery', -3)
'peoryybov'

>>> wordstem('hal')
'ate'
>>> wordstem(word='monty', beginletter='x')
'xzyej'
>>> wordstem('python')
'ajeszy'
>>> wordstem('shrubbery', beginletter='f')
'fuehoorel'

>>> rotatedWords(['bubba', 'primero', 'fyffe', 'pippo', 'sulphur'])
{('primero', 'sulphur'), ('bubba', 'fyffe', 'pippo')}
>>> rotatedWords(['beowulf', 'harahan', 'leveler', 'rhesian'])
{('harahan', 'leveler')}