1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alona [7]
3 years ago
9

Write a function: def solution (S) that, given a string S of letters "L" and "R", denoting the types of shoes in line (left or r

ight), returns the maximum number of intervals such that each interval contains an equal number of left and right shoes. For example, given S "RLRRLLRLRRLL", the function should return 4, because S can be split into intervals: "RL, "RRLL", "RL" and "RRLL". Note that the intervals do not have to be of the same size.

Engineering
3 answers:
KiRa [710]3 years ago
7 0

Answer:

# The function solution is defined with String S as argument

def solution(S):

   # number of letter R is assigned to letterRcount

   # it is initialized to 0

   letterRcount = 0

   # number of letter L is assigned to letterLcount

   # it is initialized to 0

   letterLcount = 0

   # the total count of 'RL' is assigned to total_count

   total_count = S.count("RL")

   # for loop that goes through the string

   for letter in S:

       # if the letter is R, it continue

       if(letter == 'R'):

           continue

       # once it continue, it will increment letterRcount

           letterRcount += 1

       # else if the letter is L, it will increment letterLcount

       elif (letter == 'L'):

           letterLcount += 1

   # if letterRcount is equals to letterLcount, total_count will be incremented

   if(letterRcount == letterLcount):

       total_count += 1

   # the value of total_count is returned

   return total_count

   

# the solution function is called with a string arguments

print(solution("RLRRLLRLRRLL"))

Explanation:

The program is written in python and well commented. A sample of program output is attached.

denpristay [2]3 years ago
3 0

Answer:

Please look at attachment. Thanks

Casper2 years ago
0 0

This is the correct answer for all test cases
def solution(S):
rcount=0
lcount=0
count_total=0
for c in S:
if (c=='R'):
rcount+=1
elif (c=='L'):
lcount+=1
if( rcount==lcount):
count_total+=1
rcount=0
lcount=0
return count_total

You might be interested in
Calculate the osmotic pressure of seawater containing 3.5 wt % NaCl at 25 °C . If reverse osmosis is applied to treat seawater,
AlladinOne [14]

Answer:

Highest osmotic pressure that membrane may experience is

' =58.638 atm

Explanation:

Suppose sea-water taken is M= 1 kg

Density of water = 1000 kg/m3

Therefore Volume of water= Mass,M/Density of water

V= 1 kg/(1000 kg/m3)

V= 10-3 m3= 1 Litre

Since mass of Nacl is 3.5 wt%,Therefore in 1 kg of water

Mass present of NaCl= m= 0.035*1000 g

m= 35 g

Since molecular weight of NaCl= 58.44 g/mol =M.W.

Thus its Number of moles of Nacl= m/M.W

nNaCl= 35g/58.44 gmol-1

= 0.5989 mol

ans since volume of solution is 1 L thus concentration of NaCl is ,C= number of moles/Volume of solution in Litres

C= 0.5989mol/ 1L

=0.5989 M

Since 1 mol NaCL disssociates to form 2 moles of ions of Na+ andCl- Thus van't hoff factor i=2

And osmotic pressure  = iCRT ------------------------------(1)( Where R= 0.0821 L.atm/mol.K and T= 25oC= 298.15 K)

Putting in equation 1 ,we get  = 2*(0.5989 mol/L)*(0.0821 L.atm/mol.K)*298.15 K

=29.319 atm

Now as the water gets filtered out of the membrane,the water's volume decreases and concentration C of NacL increases, thus osmotic pressure also increases.Thus, at 50% water been already filtered out, the osmotic pressure at the membrane will be maximum

Thus Volume of water left after 50% is filtered out as fresh water= 0.5 L (assuming no salt passes through semi permeable membrane)

Thus New concentration of NaCl C'= 2*C

C'=2*0.5989 M

=1.1978 M

and Since Osmotic pressure is directly proportional to concentration, Thus As concentration C doubles to C', Osmotic Pressure  ' also doubles from  ,

Thus,Highest osmotic pressure that membrane may experience is,  '=2*  

=2*29.319 atm

' =58.638 atm

3 0
3 years ago
PLEASE QUICK!!! what phrase describes an ad hominem fallacy?
Igoryamba

Answer:

personal attack

Explanation:

it is personal attack

5 0
3 years ago
HELP HELP HELP
Fantom [35]

Summary

Students learn about the variety of materials used by engineers in the design and construction of modern bridges. They also find out about the material properties important to bridge construction and consider the advantages and disadvantages of steel and concrete as common bridge-building materials to handle compressive and tensile forces.

This engineering curriculum aligns to Next Generation Science Standards (NGSS).

Engineering Connection

When designing structures such as bridges, engineers carefully choose the materials by anticipating the forces the materials (the structural components) are expected to experience during their lifetimes. Usually, ductile materials such as steel, aluminum and other metals are used for components that experience tensile loads. Brittle materials such as concrete, ceramics and glass are used for components that experience compressive loads.

Learning Objectives

After this lesson, students should be able to:

List several common materials used the design and construction of structures.

Describe several factors that engineers consider when selecting materials for the design of a bridge.

Explain the advantages and disadvantages of common materials used in engineering structures (steel and concrete).

Educational Standards

NGSS: Next Generation Science Standards - Science

Common Core State Standards - Math

International Technology and Engineering Educators Association - Technology

State Standards

Suggest an alignment not listed above

Subscribe

Get the inside scoop on all things TeachEngineering such as new site features, curriculum updates, video releases, and more by signing up for our newsletter!

PS: We do not share personal information or emails with anyone.

Email Address

First name (optional)

Last Name (optional)

Subscribe to TE Newsletter

Worksheets and Attachments

Strength of Materials Worksheet (doc)

Strength of Materials Worksheet (pdf)

Strength of Materials Worksheet Answers (doc)

Strength of Materials Worksheet Answers (pdf)

Strength of Materials Math Worksheet (doc)

Strength of Materials Math Worksheet (pdf)

Strength of Materials Math Worksheet Answers (doc)

Strength of Materials Math Worksheet Answers (pdf)

More Curriculum Like This

MIDDLE SCHOOL Activity

Breaking the Mold

Explanation:

pabrainlest Poe ty

8 0
2 years ago
Choose two consumer services careers and research online to determine what kinds of professional organizations exist for these p
Tom [10]

Answer:

Market Researcher

The Marketing Research Association (MRA) is a professional organization for market researchers. It provides information to its members on how to improve marketing research for businesses and individuals. The MRA gives its members important industry news and information through their website. Their code for marketing research standards also protects members from bad actors and improves the public perception of marketing research. The association also has a full time lobbyist representing the market research industry before government officials. The MRA has various membership categories as well. The membership fee differs for each category.  

Credit Analyst

A credit analyst is a person that reviews consumer or business financial profiles in order to give a loan or credit to them. When a business or individual applies for a credit card, loan, trade account, or another type of financial product whereby a company allows them the use of their money, a credit analyst’s job is to ensure that the consumer or business is willing and able to pay it back in the future. Credit analysts use tools such as credit reports, FICO scores, Dun & Bradstreet ratings, financial statement analyses, and personal references to perform their job. A credit analyst should have a bachelor’s degree with a major in business. Finance and economics majors are particularly suited to a credit analyst position. Certifications are not required, but some credit analysts pursue CPA or CFA (Certified Financial Analyst) designations.

Explanation:

5 0
3 years ago
8. When supplying heated air for a building, one often chooses to mix in some fresh outside air with air that has been heated fr
Afina-wow [57]

Answer:

Check the explanation

Explanation:

Kindly check the attached images below to see the step by step explanation to the question above.

5 0
3 years ago
Other questions:
  • Determine the required dimensions of a column with a square cross section to carry an axial compressive load of 6500 lb if its l
    12·2 answers
  • 5. Name two health problems that fume can cause?<br> a)....<br> b)......
    10·2 answers
  • Required information NOTE: This is a multi-part question. Once an answer is submitted, you will be unable to return to this part
    9·1 answer
  • A heat pump designer claims to have an air-source heat pump whose coefficient of performance is 1.8 when heating a building whos
    10·1 answer
  • What's a disadvantage of highest MERV-rated filters?
    10·2 answers
  • Write two scnr.nextInt statements to get input values into birthMonth and birthYear. Then write a statement to output the month,
    7·1 answer
  • An extruder barrel has a diameter of 4.22 inches and a length of 75 inches. The screw rotates at 65 revolutions per minute. The
    14·1 answer
  • A kernel-level thread wishes to acquire a mutex lock declared as global in the process. True or False: the function call used be
    6·1 answer
  • Shane's 100-watt radio draws 7 amps of current on a 120-volt circuit. What is the resistance in the radio?
    8·1 answer
  • What is resonance as in ultrasound waves formation using magnetostriction method​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!