Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

* 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

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91601919
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Question select an example of popular culture a song film

Question : Select an example of popular culture: a song, film, or music video; fashion; episodic visual storytelling such as a TV show; a print or moving image advertisement; or a magazine or book. We will refer to this ...

Explain a situation using the supply and demand for skilled

Explain a situation using the supply and demand for skilled labor in which the increased number of college graduates leads to depressed wages. Given the rising cost of going to college, explain why a college education wi ...

The scenario is to create a program for a windows company

The scenario is to create a program for a windows company. The program should display the total amount a customer owes, given the number of windows ordered and the price per window. Total owed is calculated by multiplyin ...

Show the entries for the header of a udp user datagram that

Show the entries for the header of a UDP user datagram that carries a message from a TFTP client to a TFTP server. Fill the checksum field with zeros. Choose an appropriate ephemeral port number and the correct well-know ...

Can anyone please describe how the quicksort works

Can anyone please describe how the quicksort works including a discussion of the pivot. Also how it is selected, and why the pivot is important to the quicksort.

What is the name of the text file on a windows computer

What is the name of the text file on a Windows computer that may store DNS to IP address mappings?

Question a student has a first name fname a last name lname

Question : A student has a first name (fname), a last name (lname), an identification number (id), a gender (male/female), a course name (cname) and the number of lectures (lcount) attended by the student. a. Define gend ...

In recreational mathematics a magic square is an

In recreational mathematics, a magic square is an arrangement of distinct numbers (i.e. each number is used once usually integers, in a square grid, where the numbers in each row and in each column, and the numbers in th ...

The power of the market - 1990watch and discuss the video

The Power of the Market - 1990 Watch and discuss the video - The Power of the Market http://www.freetochoose.tv/program.php?id=ftc1990_1&series=ftc90 Links to an external site. By  discuss  I mean: Overall, what did you ...

Carbonated drinks like cola tonic water and club soda are

Carbonated drinks like cola, tonic water and club soda are pleasantly bubbly due to the following decomposition of carbonic acid: H2CO3(aq) → H2O(l) + CO2(g) If a sample of H2CO3 decomposes over water at 50°C, 0.23 L of ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As