Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write code for these 3 without using any if statements, any for or while loops, any try-except statements: 1. def is_triangle_string(string: str) -> bool:+ www

write code for these 3 without using any if statements, any for or while loops, any try-except statements:

imageimageimage

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:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Auditing and Assurance Services

Authors: Timothy Louwers, Robert Ramsay, David Sinason, Jerry Straws

6th edition

978-1259197109, 77632281, 77862341, 1259197107, 9780077632281, 978-0077862343

More Books

Students also viewed these Programming questions

Question

How would you describe the work atmosphere?

Answered: 1 week ago

Question

What is a voucher?

Answered: 1 week ago