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
A gas turbine receives a mixture having the following molar analysis: 10% CO2, 19% H2O, 71% N2 at 720 K, 0.35 MPa and a volumetr
Sliva [168]

Answer:

2074.2 KW

Explanation:

<u>Determine power developed at steady state </u>

First step : Determine mass flow rate  ( m )

m / Mmax = ( AV )₁ P₁ / RT₁   -------------------- ( 1 )

<em> where : ( AV )₁ = 8.2 kg/s,  P₁ = 0.35 * 10^6 N/m^2,   R = 8.314 N.M / kmol , </em>

<em>  T₁  = 720 K . </em>

insert values into equation 1

m  = 0.1871  kmol/s  ( mix )

Next : calculate power developed at steady state ( using ideal gas tables to get the h values of the gases )

W( power developed at steady state )

W = m [ Yco2 ( h1 - h2 )co2

Attached below is the remaining  part of the detailed solution

4 0
3 years ago
Which investigative process is most helpful for learning about past societies?
tatuchka [14]

Answer: think it A

Explanation: makes

6 0
3 years ago
The amplitudes of the displacement and acceleration of an unbalanced motor were measured to be 0.15 mm and 0.6*g, respectively.
ehidna [41]

Answer:

The speed of shaft is 1891.62 RPM.

Explanation:

given that

Amplitude A= 0.15 mm

Acceleration = 0.6 g

So

we can say that acceleration= 0.6 x 9.81

acceleration,a=5.88\ \frac{m}{s^2}

We know that

a=\omega ^2A

So now by putting the values

a=\omega ^2A

5.88=\omega ^2 \0.15\times 10^{-3}

\omega =198.09\ \frac{rad}{s}

We know that

  ω= 2πN/60

198.0=2πN/60

N=1891.62 RPM

So the speed of shaft is 1891.62 RPM.

                                               

       

4 0
3 years ago
Where loads are likely to be on continuously, the calculated load for branch circuits and feeders must be figured at (100%) (125
Anna [14]

Where loads are likely to be on continuously, the calculated load for branch circuits and feeders must be figured at 125%.

Section 210.19(A)(1) permits the bigger of the two values listed below to be utilized as the connectors 's ultimate size for sizing an ungrounded branch circuit conductor:

Without any extra adjustments or corrections, either 125% of the continuous load, OR

When adjustment and corrective factors are applied, the load is 100% (not 125% as stated previously).

This will be the same in the 2020 NEC. The introduction of new exception 2 is what has changed. To comprehend this new exception, one must study it very carefully. A part of a branch circuit connected to pressure connectors (such as power distribution blocks) that complies with 110.14(C)(2) may now be sized using the continuous load plus the noncontiguous load instead of 125% of the continuous load thanks to the new exception.

To know more about connectors click here:

brainly.com/question/16987039

#SPJ4

4 0
1 year ago
A cold air standard gas turbine engine with a thermal efficiency of 56.9 % has a minimum pressure of 100 kP
Aleks04 [339]

Answer:

a) 5.2 kPa

b) 49.3%

Explanation:

Given data:

Thermal efficiency ( л ) = 56.9% = 0.569

minimum pressure ( P1 ) = 100 kpa

<u>a) Determine the pressure at inlet to expansion process</u>

P2 = ?

r = 1.4

efficiency = 1 - [ 1 / (rp)\frac{r-1}{r} ]

   0.569   = 1 - [ 1 / (rp)^0.4/1.4

1 - 0.569  = 1 / (rp)^0.285

∴ (rp)^0.285 = 0.431

rp = 0.0522

note : rp = P2 / P1

therefore P2 = rp * P1 = 0.0522 * 100 kpa

                                   = 5.2 kPa  

b) Thermal efficiency

Л = 1 - [ 1 / ( 10.9 )^0.285 ]

   = 0.493 = 49.3%

4 0
3 years ago
Other questions:
  • 7. Which power source is an important transition between
    7·1 answer
  • Vapor lock occurs when the gasoline is cooled and forms a gel, preventing fuel flow and
    7·2 answers
  • Refrigerant 134a enters a horizontal pipe operating at steady state at 40oC, 300 kPaand a velocity of 40 m/s. At the exit, the t
    13·1 answer
  • Describe the relationship between atomic structure and Youngs' modulus?
    15·1 answer
  • What is kinetic energy?
    5·2 answers
  • The temperature controller for a clothes dryer consists of a bimetallic switch mounted on an electrical heater attached to a wal
    12·1 answer
  • What do you think of web 3.0? do you think it will be realized someday in the future?​
    5·1 answer
  • Which outcome most accurately portrays the future for the timber company in the following scenario?
    9·1 answer
  • Software that is released to have users test out the "bugs" is known as Ransomeware O Break-in software 2 O Flim flam software O
    15·1 answer
  • Workers who work with what kind of chemicals chemicals may require regular medical checkups on a more frequent basis as a result
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!