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
-
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...
-
Green Lawns, Inc., performs adjusting entries every month, but closes its accounts only at year-end. The company's year-end adjusted trial balance dated December 31, 2015, was: a. Prepare an income...
-
Place a sheet of paper under a medium-sized book lying on a smooth tabletop or desktop. a. Try to accelerate the book smoothly by exerting a constant pull on the sheet of paper. What happens if you...
-
Tandrin Aviation Holdings Ltd. agreed to sell a jet aircraft to Aero Toy Store, LLC, for \($31.75\) million. ATS paid a \($3\) million deposit to a third party with the balance due upon delivery....
-
Complete Keith's tax return including all required schedules and forms using prince edward island as province, using the fillable forms package. Taxpayers Information Taxpayer #1 Name: Keith Dox...
-
Why socialism or communism doesn't work in Russia but does in China? as in other countries that we see today. What do you think was the cause of the end of socialism or communism?
-
You need to write a Job Description Template for Skyline International College
-
How do lenders usually size the debt in a leveraged buyout?
-
Im writing a critical analysis essay relating back to ethical concerns and need help writing a body paragraph on "The article "Activision Blizzard sued by U.S. government for violating labor laws" ...
-
Briefly define and explain Applicability and Satisfaction as they apply to the legal framework of the Fourth Amendment.
-
Regarding the Private Search Doctrine, how could a person lose the reasonableness of an expectation of privacy? Provide an example, if necessary.
-
1. Prove that, for any set, say A, 05 A. 2. If A has 63 proper subsets, what is JA]. 3. For any non-empty sets A and B, define a function from A to B. 4. Let A, B be sets with (B) = 3. If there are...
-
Question: Explain the various functional areas that exist in Functional Area Information Systems, and explain how efficient and effective each area is!
-
A company pledges their receivables so they may Multiple Choice Charge a factoring fee. Increase sales. Recognize a sale. Collect a pledge fee. Borrow money. Failure by a promissory notes' maker to...
-
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?
-
(a) A photon of energy \(E_{0}\) strikes a free electron at rest in the lab. ("Free" here means the electron is not bound inside an atom.) Is it possible for the photon to be absorbed by the...
-
The quantity \(\lambda_{C} \equiv h / m_{e} c\) is called the "Compton wavelength" of the electron. (a) If a photon scatters off an electron at rest with scattering angle \(\theta=45^{\circ}\), what...
-
The Captain of an interstellar photon-rocket spaceship wishes to maintain a constant acceleration \(a\) in the instantaneous rest-frame of the ship, since that would provide a constant effective...
Study smarter with the SolutionInn App