Level 1 Clocking in and out
Build Office, which tracks when employees are physically at work.
add_employee(employee_id, position, hourly_salary) -> bool: register someone.Falseif the id is taken.clock_in(employee_id, timestamp) -> bool: the employee arrives.False(and nothing changes) if the employee doesn't exist or is already clocked in.clock_out(employee_id, timestamp) -> bool: the employee leaves, closing the session[clock_in time, timestamp).Falseif the employee doesn't exist or isn't clocked in.get_total_work_time(employee_id) -> int | None: the summed length of all finished sessions (a session still open doesn't count yet).Nonefor an unknown employee.
Timestamps passed to clock_in / clock_out strictly increase from call to call.
office = Office()
office.add_employee("e1", "Engineer", 10)
office.clock_in("e1", 100)
office.clock_in("e1", 120) # False, already in
office.clock_out("e1", 150) # True
office.get_total_work_time("e1") # 50
office.clock_out("e1", 160) # False, not in