A mirror has the following


* Python Program 

Write and test the following function:

def mirror(s, v, m, m):
    """
    -------------------------------------------------------
    Determines if s is a mirror of characters in v around the pivot m.
    Use: r = mirror(s, v, m)
    -------------------------------------------------------
    Preconditions:
        s - a string (str)
        v - a string of valid characters (str)
        m - the mirror pivot string (str not in v)
    Postconditions:
        returns
        is_mirror - True if s is a mirror, False otherwise (bool)
    -------------------------------------------------------
    """

A mirror has the following pattern: LmR where L is a (possibly empty) string formed from the letters of a string, and R is the reverse of the string L. m is an pivot string whose characters are not in L or R. For example, the following strings have the abc mirror pattern: "m", "abacmcaba", "cmc", "bbaamaabb". The following strings do not have the abc mirror pattern: "abmb", "gmg", "abacmcabb".

Examples:

>>> print(mirror('abcmcba', 'abc', 'm'))
True
>>> print(mirror('cmc', 'c', 'm'))
True
>>> print(mirror('bbaattaabb', 'ab', 'tt'))
True
>>> print(mirror('abmb', 'ab', 'm'))
False
>>> print(mirror('gmg', 'ab', 'm'))
False
>>> print(mirror('atta', 'at', 'tt'))
False

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: A mirror has the following
Reference No:- TGS01237664

Now Priced at $20 (50% Discount)

Recommended (92%)

Rated (4.4/5)