String formed from the letters of a string

Assignment Help Basic Computer Science
Reference no: EM13929040

* 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

Reference no: EM13929040

Questions Cloud

Evaluate the use of a distributed database management system : Evaluate the use of a Distributed Database Management System (DDBMS). As with most things, there are numerous advantage and many disadvantages. Evaluate and rank them. What would be good situations to use a DDBMS and why?
Understanding financial statements : Write a 750- to 1,050-word paper evaluating the financial health of a company. Highlight the importance of industry comparisons and trends.
Characteristic shared and inherited from a common ancestor : What term is used to indicate a characteristic that is shared and inherited from a common ancestor?
Here a median is the middle element of a sorted list : Here a median is the middle element of a sorted list if the number of elements is odd, and the average of the two middle elements if the number of elements is even. You may use Python's built-in sort method to sort the contents of the list after they..
String formed from the letters of a string : 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 t..
How communication involved in carrying out these strategies : Identify and analyze three strategies you feel are critical to for leaders to apply when facilitating collaborative sessions. How is communication involved in carrying out these strategies?
How cloud based office productivity software is different : Remember to state business problem, articulate the current setup, explain how cloud based office productivity software is different, and how it benefit the business
Problem regarding the accounting software memo : Your department's accounting software is extremely outdated and you have included the purchase of new software in this year's fiscal budget. You have decided it is time to start looking into purchasing your company's accounting software and have c..
What is the book value of the asset at the time of sale : How would the sale affect the amount of total assets shown on the balance sheet (increase, decrease, no effect) and by how much?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Compare and contrast quantitative optimization

Compare and contrast (i) quantitative optimization-based design, and (ii) experience-based design.

  Determine pz and also estimate any constants

Determine P(z) and also estimate any constants in this expression so that P(z) is given in terms only of  and μ. If possible eliminate any common factors in numerator and denominator of this expression

  Scripts to automate user and group maintenance

Need assistance and examples to start a report based upon the following information generated from any UNIX like interface, preferably Ubuntu or Cygwin. Need UNIX scripts for the following actions: (1) A script to automate the shutdown process and a ..

  What is the frequency of the ripple voltage

What is the frequency of the ripple voltage for a negative output half-wave rectifier with an input of 120 Vrms, 60 Hz?

  What do you think of ai

What do you think of AI. Do you exalt AI? Do you think that there are also dangers involved? Please discuss the benefits and the perils of artificial intelligence and everything about AI.

  Add an embedded style sheet

Add an embedded style sheet to set the following: a. links class (no pseudoclasses): position of the text should be absolute and 150 pixels from the top; the text should display in a block, center-aligned in bold with 1em sans-serif; padding of te..

  Describe the legal requirements and ethical issues

Analyze the software tools you would use for your investigation and reasons for choosing them. Describe the legal requirements and ethical issues involved.

  Give a polynomial-time algorithm to find a subset

So this is the question they pose to you: Which of the remaining applications, if any, should be moved? Give a polynomial-time algorithm to find a subset S of {2, 3,..., n} for which the sum of the benefits minus expenses of moving the application..

  Clg lyk colg placement information

CLG lyk colg placement information and tieup with companys information

  Any rfcs that discuss sip trunking

Write a 500-word paper that explains what a SIP trunk is, why you would use a SIP trunk, the equipment required for its use, and any RFCs that discuss SIP trunking.

  Audience is the way ideas are organized and presented

Audience is the way ideas are organized and presented in a text

  A topic relevant to current information

Select two articles on a topic relevant to current information security trends and describe its impact on business; assess the steps industry should take to address it. Formatting: APA style paper, double spaced, two pages, Cover page, reference ..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd