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

  Identify potential weaknesses of quality web design company

Identify potential weaknesses from either the Aircraft Solutions or Quality Web Design Company. In this phase, you will choose either Aircraft Solutions or Quality Web Design as the company you will work with.

  Creating modular program to enter monthly costs

Create a modular program which asks the user to enter monthly costs for expenses given incurred from operating his or her automobile.

  Research a computer organization

You are to research a computer organization/computer architecture topic and present your findings in a research paper. You should read various reference materials to gather information, which then should be presented in a logically organized and c..

  How matrices are calculated

Show each of the intermediate matrices. Refer to section 9-1 of the textbook for the details of how matrices are calculated. Because no translations are involved, you can use 3 x 3 matrix math for your calculations.

  Instruction cycle and finding contents of registers

Go over instruction cycle and find out contents of registers PC, AR, DR, AC, and IR for each of seven memory-reference instructions.

  Explain where one particular technology or method

Explain where one particular technology or method has won out over the competition in the corporate world. Identify the reasons that led to this particular technology being preferred within the business realm. Include a question that responding..

  Write some code that swaps their values

Given two int variables, firstPlaceWinner and secondPlaceWinner , write some code that swaps their values. Declare any additional variables as necessary.

  What are the overall benefits of having professional codes

What are the overall benefits of having professional codes? Do the benefits outweigh the disadvantages of not having them? Find a current case involving ethical standards.

  How could a business use information technology

How could a business use information technology to increase switching costs and lock in its customers and suppliers? Use business examples to support your answers

  Explain an it organizational leader in a mid-sized company

an IT organizational leader in a mid-sized company, and determine the type of enterprise system that your company would choose for an initial implementation if your company were to move away from legacy systems

  Innovation in info tecnology

innovation in info tecnology

  Will autonation can continue to be successful

How have they responded to pressures from its competitive environment? How does it provide value to its customers? Do you think AutoNation can continue to be successful?

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