Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 find-practice.time (), which takes a single argument: e 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 same time. 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. CSE 101 - Spring 2019 Lab #6 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-list inside student_time_tables: if a student is free in the morning, then if a student is free in the afternoon, thern if a student is free in the evening, then add 1 to the count of students available in the morning add 1 to the count of students available in the afternoon 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' Evening' [0,1,1], [1,1,01, [1,1,0], [0,0,1], [1,0,0], [0,0,111 Morning" 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started