A Discrete Mathematics professor has a class of students. Frustrated with their lack of discipline, the professor decides to cancel class if fewer than some number of students are present when class starts. Arrival times go from on time (arrivaltime≤0) to arrived late (arrivaltime>0).Given the arrival time of each student and a threshold number of attendees, determine if the class is cancelled.
A straight forward hackerrank problem where we calculate the number of student who come on time and depending on the threshold attendees the class is conducted else it won’t be conducted.
First we will iterate the list holding the class in-time.we will declare a counter and give it an initial value 0. After then we will check if each student enters the class before or on the specified class time. if the student comes on time or before time we will increment the counter by 1.Once entire list is iterate we will check the counter value with the threshold value if the threshold value is statisfy we will return “No” which means class is not cancelled else we will return “Yes” value which means the class is cancelled.
def angryProfessor(k, a):
for i in a:
“Time and tide waits for no-one”-we have read this phrase since our childhood but understands it quite late in life.Happy learning and it never too late to take a fresh start……(cheer:-PN)