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.
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:
Write a function rotation that prints the $$r$$-rotation ($$r \in \mathbb{N}$$) of a given word as a result. To this function two parameters must be given: the given word (a string that consist of lowercase letters) and the value $$r$$.
The word stem of a word is the rotated word that starts with a given begin letter. Use the function rotation to write a function wordstem that prints the word stem of a given word that starts with a given begin letter. As a first obligatory parameter word a word should be given to the function that consists solely of lowercase letters. The function also has a second, optional parameter beginletter, which can be used to give the begin letter of the stem word. The letter a is used as a standard begin letter.
Use the function wordstem to write a function rotatedWords. To this function a list of words (consisting of lowercase letters) must be given. The function must print a collection of tuples as a result, where every tuple contains all words from the given word list that are rotated words of each other. Every tuple from the collection contains two or more words, that must be ordered alphabetically.
>>> 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')}