Question: PYTHON Let D be the number of rows in a class. The function you will write is this number as argument and a series The
PYTHON
Let D be the number of rows in a class. The function you will write is this number as argument and a series The integer will take the number as an argument in list form.
for example: [D,s1,s2,s3,. . .]
Where D is the total number of rows in class and s1, s2. . is the number of rows that are full. All rows are arranged in two columns. S1 in front left and s2 in front right, s3 behind s1 and Behind s2 is s4. The order continues in this way.
So the class looks like this;
s1 s2 s3 s4 s5 s6 . . . .
The function's argument [[12,2,6,7,11]] means there are a total of 12 rows in the classroom and rows 2,6,7 and 11 are full. The class can be thought of as follows.
Column1 [[#, 4, #, 8,10,12]] s2 and s6 full
Column2
[[1,3,5, #, 9, #]] s7 and s11 are occupied.
# indicates a full row.
According to these rules, two students can be side by side or back and forth, how many different sitting positions? it may be. Possible combinations for the above case: [[1,3],[3,4],[3,5],[8,10],[9,10],[10,12]]
There are a total of 6 cases.
Considering that the number D will always be even and the number of rows from 0 to D
place_student([]) Write down the function.
for example:
place_student([8,1,8]) > 6 place_student([6,4]) > 4 place_student([12,2,6,7,11]) > 6
8,1,8 The first number 8 is the value of the total number of rows (D) in the class. Other numbers 1 and 8 are numbers 1 and 8. indicates that the rows are full. The question is, how many different two students are side by side? Possible combinations for the above case [[2,4],[3,4],[3,5],[4,6],[5,6],[5,7]] There are a total of 6 cases. So output 6 will be for example input 1=> 8,1,8 output1=>6 input 2=>6,4 output2=>4
input 3=>12,2,6,7,11 output 3=>6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
