This code takes in student attendance data and calculates the maximum number of students who attended class simultaneously. It first converts the start and end times to seconds, then counts the number of students present at each time interval. It finds the time stamps with the minimum simultaneous attendance and identifies which students were present during those times. The greatest common divisor of the counts is then calculated and printed as the ratio of the maximum simultaneous attendance.
This code takes in student attendance data and calculates the maximum number of students who attended class simultaneously. It first converts the start and end times to seconds, then counts the number of students present at each time interval. It finds the time stamps with the minimum simultaneous attendance and identifies which students were present during those times. The greatest common divisor of the counts is then calculated and printed as the ratio of the maximum simultaneous attendance.
Original Description:
This is a file to automatically capture the attendance of students in class with face fetect
This code takes in student attendance data and calculates the maximum number of students who attended class simultaneously. It first converts the start and end times to seconds, then counts the number of students present at each time interval. It finds the time stamps with the minimum simultaneous attendance and identifies which students were present during those times. The greatest common divisor of the counts is then calculated and printed as the ratio of the maximum simultaneous attendance.
This code takes in student attendance data and calculates the maximum number of students who attended class simultaneously. It first converts the start and end times to seconds, then counts the number of students present at each time interval. It finds the time stamps with the minimum simultaneous attendance and identifies which students were present during those times. The greatest common divisor of the counts is then calculated and printed as the ratio of the maximum simultaneous attendance.
l=[] for i in range(n): l.append(input()) def getseconds(date): h,m,s = list(map(int,date.split(':'))) return h*60*60 + m*60 + s start = getseconds(start) end = getseconds(end) duration = end-start+1 r = [0 for i in range(duration+1)] time_attended={} for item in l: temp = list(item.split(' ')) time_attended[temp[0]] = [] i=2 while(i<len(temp)): s,e = getseconds(temp[i]), getseconds(temp[i+1]) i+= 2 s,e=s-start, e-start r[s]+=1 r[e]-=1 time_attended[temp[0]].append([s,e-1]) time_stamps_of_min = set() new = [] new.append(r[0]) for i in range(1,len(r)-1): new.append(r[i]+new[-1]) new.pop() mini = min(new) for i in range(len(new)): if(new[i]==mini): time_stamps_of_min.add(i) set_SID1 = set() for item in time_attended['1']: set_SID1 = set_SID1.union(set(range(item[0],item[1]+1))) set_SID1= set_SID1.intersection(time_stamps_of_min) import math if(len(set_SID1)==0): print(0) else: a,b = len(set_SID1), len(time_stamps_of_min) c = math.gcd(a,b) print(a//c,'/',b//c,sep='')