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

  Explaining mismatched file headers to extensions

What procedures would you require to follow to retrieve evidence? Identify mismatched file headers to extensions.

  Write a function named getrandomaverage

Write a function named "getRandomAverage" that uses a "for" loop to compute the average of random numbers. The function receives the quantity of numbers to be averaged and returns the average of all thevalues. It does not print any output from within..

  Compare and contrast public and in-house cas

Compare and contrast public and in-house CAs

  Identify the comment object returned

Create tests for SalesItem that test whether the findMostHelpfulComment method works as expected. Note that this method returns a Comment object.

  What is the ip address of your nic or network adapter

What is the IP address of your NIC or Network adapter? what is the IP address listed for your default gateway?

  Spreadsheet applications (excel)

The Excel PMT function is used to calculate the payment for a loan based on constant payments and a constant interest rate.

  Related to web services

A review paper usually should include multiple (about 5) references. I would like to see references from referred conference proceedings or journals.

  Decision tables and dependency diagrams

Decision Tables and Dependency Diagrams

  Manages the deletion of users

To do some basic administration work using common tools and configure/ install a package-Write down the command you would enter to create a account for the staff member Steven Jobs. The user should have a home directory in /homeand should belong to..

  What is the default file extension for a file saved in word

Alan wants to find an image of a car he can use in a presentation. What button should he click in the Images group to run a search. What is the default file extension for a file saved in Word 365

  Create a shadow on the phrase html5 canvas

Create a shadow on the phrase "HTML5 Canvas" with an offset -x of 2px, an offset -y of 5px, a blur of 6px, and a text shadow color grey.

  Successful at attracting and keeping purchasing customers

Successful at attracting and keeping purchasing customers

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