write code for these 3 without using any if statements, any for or while loops, any try-except
Fantastic news! We've Found the answer you've been seeking!
Question:
write code for these 3 without using any if statements, any for or while loops, any try-except statements:
Transcribed Image Text:
1. def is_triangle_string(string: str) -> bool:+ www Given an input in the form of some string that looks like "111222333", return True if is a triangle string, False otherwise. For the purposes of this function, we define a triangle string as a string which could represent a proper triangle if its characters were converted into the sides of a triangle. What we mean by this is, if let's say the three distinct characters within the string each represented one side of the triangle, and the number of occurrences of each distinct character represented the length of that side, and those three sides could form a proper triangle as defined in lab 2, then is a triangle string. Precondition: will be a string with three distinct characters, and there will be exactly two positions within the string where adjacent characters differ (are different). The length of will always be >= 3. Note that the characters do not have to be 1, 2 and 3 like the example given above, they could be any printable character. Restrictions: you must use your "exists_triangle" function from lab 2 as a helper for this function, in addition to the lab restrictions defined at the start of this file. You are allowed and are encouraged to fix any issues with your previous submission for this function. More explicitly, this means that somewhere within the body of this function, there must be a function call to the "exists_triangle" function defined above. Please remember to write doctests, you must write them below this line: 1. def is_triangle_string(string: str) -> bool:+ www Given an input in the form of some string that looks like "111222333", return True if is a triangle string, False otherwise. For the purposes of this function, we define a triangle string as a string which could represent a proper triangle if its characters were converted into the sides of a triangle. What we mean by this is, if let's say the three distinct characters within the string each represented one side of the triangle, and the number of occurrences of each distinct character represented the length of that side, and those three sides could form a proper triangle as defined in lab 2, then is a triangle string. Precondition: will be a string with three distinct characters, and there will be exactly two positions within the string where adjacent characters differ (are different). The length of will always be >= 3. Note that the characters do not have to be 1, 2 and 3 like the example given above, they could be any printable character. Restrictions: you must use your "exists_triangle" function from lab 2 as a helper for this function, in addition to the lab restrictions defined at the start of this file. You are allowed and are encouraged to fix any issues with your previous submission for this function. More explicitly, this means that somewhere within the body of this function, there must be a function call to the "exists_triangle" function defined above. Please remember to write doctests, you must write them below this line:
Expert Answer:
Related Book For
Auditing and Assurance Services
ISBN: 978-0077862343
6th edition
Authors: Timothy Louwers, Robert Ramsay, David Sinason, Jerry Straws
Posted Date:
Students also viewed these programming questions
-
Flixable reports that Netflix's U.S. catalog contains almost 4000 movies.9 You are interested in determining the average length of these movies. Previous studies have suggested the standard deviation...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Read the case study "Southwest Airlines," found in Part 2 of your textbook. Review the "Guide to Case Analysis" found on pp. CA1 - CA11 of your textbook. (This guide follows the last case in the...
-
Window World extended credit to customer Nile Jenkins in the amount of $130,900 for his purchase of window treatments on April 2. Terms of the sale are 2/60, n/150. The cost of the purchase to Window...
-
The following account balances were taken from Harris Corporation's year-end adjusted trial balance (assume these are the company's only temporary accounts): Dividends . . . . . . . . . . . . . . . ....
-
Warner Containers currently uses a recycled plastic to make bottles for the food industry. Current bottle production information: The cost and time standards per batch of 10,000 bottles are as...
-
The annual report of Starbucks Corporation for the year ended September 29, 2013, included information on seven investments in which Starbucks generally held a 50 percent ownership interest. Thus...
-
Kitchen Help Inc. (KHI) is a manufacturer of toaster ovens. To improve control over operations, the president of KHI wants to begin using a flexible budgeting system, rather than use only the current...
-
The Marevick Company bought land and built a warehouse during 2019. The following costs were incurred related costs to Land and Building account: Land and unusable building purchased P 400,000...
-
1. Assume a 30% tax rate, and the Totals per financial statements provided. Complete the following schedule as per Figure 16.4. Assume that the Totals per financial statements (second to bottom row)...
-
The gollowing gradienh o7 he poleuwing a) Feays}) = e* Sincy) lucz) Cot(2) find lhe Functions 3 %3D
-
How can leaders balance the demands of maintaining operational efficiency with the need to cultivate employee well-being and resilience, especially in the context of global disruptions such as...
-
a. George Gershwin Co. sold $2,000,000 of 10%, 10-year bonds at 104 on January 1, 2025. The bonds were dated January 1, 2025, and pay interest on July 1 and January 1. If Gershwin uses the...
-
Explain how the tips helped you improve your Summary/Response essaY Summarizing a text boiling it down to its basic ideas helps us to see and understand its main points, think about what it says,...
-
Write in first person: Researchers can provide a clear grasp of the anticipated link between the variables under study by developing a hypothesis. In this instance, the theory contends that a few key...
-
The ultimate goal of this class is to apply its concepts to real-world phenomena. In this question we want to give you a (further) chance to do that using everything we've learned so far. As such,...
-
Emily Smith and Russel Barton decided to set up a business selling electronic products online. They registered a proprietary company called ER Electron Pty Ltd on 1 July 2 0 2 2 . The company s...
-
What mass of H2 will be produced when 122 g of Zn are reacted? Zn(s) + 2HCl(aq) ( ZnCl2(aq) + H2(g)
-
When auditing the existence assertion for an asset, auditors proceed from the a. Financial statement amounts back to the potentially unrecorded items. b. Potentially unrecorded items forward to the...
-
What is a system of quality control? Identify the six elements of a system of quality control.
-
What is a voucher?
-
1.8 Krisianto's Competing Job Offers. Krisianto, after an intensive post-graduation job search, has received job offers from three multinational companies. Each posi- tion is based in a different...
-
1.10 Blundell Biotech. Blundell Biotech is a U.S.-based biotechnology company with operations and earn- ings in a number of foreign countries. The company's profits by subsidiary, in local currency...
-
1.9 Comparing Cheap Dates Around the World. Com- parison of prices or costs across different country and currency environments requires translation of the local currency into a single common cur-...
Study smarter with the SolutionInn App