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
2. There are three drawings that architects and designers use to indicate spaces. What are these drawing?
Zarrin [17]

Answer:

Architectural plans.

Explanation:

An architectural plan is called the drawings made by architects, civil engineers or designers of spaces or interiors, in which these professionals capture their building projects, organizing the distribution of the spaces to be used, the elements to be located in them and, fundamentally, to give construction planning a projection into reality. Thus, the plans help professionals to have a better understanding of the expected end result of the projects they are carrying out.

3 0
3 years ago
How to make a police car ​
S_A_V [24]

search it and you will get on internet

3 0
2 years ago
Robomind academy code if hour
Anvisha [2.4K]
Erm what? ......;-;
7 0
3 years ago
You want to plate a steel part having a surface area of 160 with a 0.002--thick layer of lead. The atomic mass of lead is 207.19
Pepsi [2]

Answer:

<u><em>To answer this question we assumed that the area units and the thickness units are given in inches.</em></u>

The number of atoms of lead required is 1.73x10²³.    

Explanation:

To find the number of atoms of lead we need to find first the volume of the plate:

V = A*t

<u>Where</u>:

A: is the surface area = 160

t: is the thickness = 0.002

<u><em>Assuming that the units given above are in inches we proceed to calculate the volume: </em></u>

V = A*t = 160 in^{2}*0.002 in = 0.32 in^{3}*(\frac{2.54 cm}{1 in})^{3} = 5.24 cm^{3}    

Now, using the density we can find the mass:

m = d*V = 11.36 g/cm^{3}*5.24 cm^{3} = 59.5 g

Finally, with the Avogadros number (N_{A}) and with the atomic mass (A) we can find the number of atoms (N):

N = \frac{m*N_{A}}{A} = \frac{59.5 g*6.022 \cdot 10^{23} atoms/mol}{207.19 g/mol} = 1.73 \cdot 10^{23} atoms    

Hence, the number of atoms of lead required is 1.73x10²³.

I hope it helps you!

3 0
3 years ago
2 Blocks 1 and 2 rest on rough surfaces with coefficient of frictions ¢1 and ¢2 respectively. The blocks
Amiraneli [1.4K]

Answer:

  • 100N
  • 25N

Explanation:

a) On the verge of tipping over, reaction acts at the corner A

When slippage occurs,

Block moves w/ const. velocity  equilibrium

Three-force member: reaction at A must pass through B

tan b/2h, h b/ 2 θ µ = = ∴= k k ( µ )

b) When slippage occurs,

Block moves w/ const. velocity  equilibrium

Three-force member: reaction at C must pass through G

k tanθ µ =

tan x/ H/2 , x H/2

4 0
3 years ago
Other questions:
  • A frustum of cone is filled with ice cream such that the portion above the cone is a hemisphere. Define the variables di=1.25 in
    9·1 answer
  • A steel rectangular tube has outside dimensions of 150 mm x 50 mm and a wall thickness of 4 mm. State the inside dimensions, the
    5·1 answer
  • If a pendulum takes 2 sec to swing in each direction, find the period and the frequency of the swing
    15·1 answer
  • Item110pointseBook HintPrintReferences Check my work Check My Work button is now disabled5Item 1Item 1 10 pointsAn ideal Diesel
    10·1 answer
  • Which actions would the maintenance and operations crews carry out as a building is completed and preparing to open to the publi
    8·2 answers
  • Consider coaxial, parallel, black disks separated a distance of 0.20 m. The lower disk of diameter 0.40 m is maintained at 500 K
    13·1 answer
  • There is a black-box system (i.e we do not know the transfer function of the system). When we fed a step input into the system,
    9·1 answer
  • What is the physical mechanism that causes the friction factor to be higher in turbulent flow?
    13·1 answer
  • Contrast moral and immoral creativity and innovation<br>​
    12·1 answer
  • The inspector should inspect insulation in unfinished spaces, including attics, _____ and foundation areas.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!