Jean-François Sudre1 (15 August 1787 – 3 October 1862) had a unique thought in 1817: if people of different cultures can appreciate the same music, why not develop music itself into an international language? The constructed language that he devised based on this idea — which he called Solresol — enjoyed a brief spell of popularity, reaching its pinnacle with Boleslas Gajewski's 1902 posthumous publication of Grammaire du Solrésol.

Solresol is a musical language based on the principles of solfège, a music education method used to teach the pitch and sight singing. Theoretically, Solresol communication can be done through speaking, singing, flags of different color — even painting. Solresol words are made up of from one to five syllables or notes. Each of these may be one of only seven basic phonemes that correspond to the seven familiar notes of the solfeggio scale: do, re, mi, fa, sol, la, si. These phonemes have been used to compose a vocabulary of 2600 roots.

solresol
The seven conventional notes, colors, syllables, numerals, and glyphs used to convey solresol phonemes.

Like other constructed languages with a priori vocabulary, longer Solresol words are divided into categories of meaning, based on their first syllable. Words beginning with sol have meanings related to arts and sciences. Words that begin with solsol are related to sickness and medicine. Related words thus share initial syllables. For example, doremi means day, dorefa means week, doresol means month and doredo the concept of time itself. A unique feature of Solresol is that meanings are negated by reversing the syllables in words. For instance fala means good or tasty, and lafa means bad.

The teaching of sign languages to the deaf was discouraged between 1880 and 1991 in France, contributing to Solresol's descent into obscurity. After a few years of popularity, Solresol nearly vanished in the face of more successful languages, such as Volapük2 and Esperanto3. There is still a small community of Solresol enthusiasts scattered across the world, better able to communicate with one another now than previously thanks to the Internet. For example, in the Steven Spielberg movie Close Encounters of the Third Kind4 the aliens use Solresol to communicate with the human race.

Preparation

Watch the learning clip about test-driven development5 to see how you can make use of doctests. This will allow you to understand the last two statements in the skeleton of the source code that is given in the assignment.

Assignment

You are given the following skeleton of the source code that must lead to the solution of this exercise.

def isSolresol(word):

    """
    Returns a Boolean value that indicates whether or not the given word meets
    the grammar rules of Solresol.
    
    >>> isSolresol('doresol')
    True
    >>> isSolresol('doreso')
    False
    >>> isSolresol('salami')
    False
    """

def shorthand(word):

    """
    Returns the shorthand notation of the given Solresol word.
    
    >>> shorthand('fala')
    'fl'
    >>> shorthand('doremi')
    'drm'
    >>> shorthand('doresol')
    'drso'
    """

def opposite(word):

    """
    Returns the opposite of the given Solresol word.
    
    >>> opposite('fala')
    'lafa'
    >>> opposite('doremi')
    'miredo'
    >>> opposite('doresol')
    'solredo'
    """

if __name__ == '__main__':
    import doctest
    print(doctest.testmod())

Your task is to implement the three functions in this code fragment, so that the functions meet the following descriptions.

You may assume that all arguments passed to the functions shorthand and opposite represent words that match the grammar rules of Solresol, as defined in the description of the function isSolresol.

Example

>>> isSolresol('doresol')
True
>>> isSolresol('doreso')
False
>>> isSolresol('salami')
False

>>> shorthand('fala')
'fl'
>>> shorthand('doremi')
'drm'
>>> shorthand('doresol')
'drso'

>>> opposite('fala')
'lafa'
>>> opposite('doremi')
'miredo'
>>> opposite('doresol')
'solredo'