Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

******** I pass all test except for one where the student time tables are [[0, 0, 1], [1, 0, 1], [1, 1, 0], [1, 0,

image text in transcribedimage text in transcribed

******** I pass all test except for one where the student time tables are [[0, 0, 1], [1, 0, 1], [1, 1, 0], [1, 0, 0], [0, 1, 1], [0, 1, 1]], the expected return value is evening but i am getting morning with this code***********

def find_time(student_time_tables): counts = [0, 0, 0] for i in student_time_tables: if i[0] == 1: counts[0] += 1 if i[1] == 1: counts[1] += 1 if i[2] == 1: counts[2] += 1 if counts[0] == counts[1] or counts[0] == counts[2]: return "Morning" if counts[1] == counts[2]: return "Afternoon" if counts[0] > counts[1] and counts[0] > counts[2]: return "Morning" if counts[1] > counts[0] and counts[1] > counts[2]: return "Afternoon" if counts[2] > counts[0] and counts[2] > counts[1]: return "Evening" 

The coach of Stony Brook University's Basketball team wants to organize practice sessions for the team. He has three time slots, namely, Morning, Afternoon and Evening. He is given the time table of all the students in the form of a 2D list of integers, i.e., a list of lists of integers. You need to help the coach to find an appropriate time where the maximum students are available for practice. Write the function findpractice.timeO,which takes a single argument: student.time.tables: a 2D list of integers representing students time table where 1 means that the student is free in that time slot and 0 meaning the student has a class Each individual sub-list inside the overall list always have three values: some combination of Os and 1s. For example, the sub-list [1, 0, 1] means the student is available for practice in the morning and evening, but not in the afternoon. The following rules apply: . The coach knows that it is impossible for all students to be free at the samtime. He will hold practice when maximum number of students are available. The coach wants to hold practice as early in the day as possible. So, for example, if there is a tie between afternoon and evening, the practice will take place in the afternoon. It is guaranteed that at least 1 student is free in 1 time slot, i.e. it is not possible to have a list of all zeroes. The function returns a string 'Morning', 'Afternoon' or 'Evening' depending on the above rules Clearly we need to iterate over all the time slots of all the students. We also could iterate over each of the sub-lists of 3 elements each if we like. See the pseudocode below: for each sub-1ist inside student_time_tables: if a student is free in the morning, then add 1 to the count of students available in the morning if a student is free in the afternoon, then add 1 to the count of students available in the afternoon if a student is free in the evening, then add 1 to the count of students available in the evening Note that the 3 if-statements above can be replaced with a single for-loop that iterates 3 times if we store the 3 counts in a list of integers of length 3 Examples: Function Arguments Return Value Afternoon' C0,1,1,(1,0,11,[0,1,11,1,0,11,10,0,11,I0,1,011Evening [0,1.1),(1.1,01,11.1,01,10,0,11,11,0,01,10,0,111 'Morning' Please note that the tests in the tester program are different from the ones provided in the above table

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

Mysql Examples Explanations Explain Examples

Authors: Harry Baker ,Ray Yao

1st Edition

B0CQK9RN2J, 979-8872176237

More Books

Students also viewed these Databases questions

Question

an element of formality in the workplace between different levels;

Answered: 1 week ago