const shifts = [
{ time: 400, value: 0.03, hadRecentInput: false },
{ time: 1100, value: 0.04, hadRecentInput: false },
{ time: 2600, value: 0.2, hadRecentInput: true },
{ time: 3000, value: 0.04, hadRecentInput: false },
{ time: 3800, value: 0.05, hadRecentInput: false },
{ time: 4600, value: 0.03, hadRecentInput: false },
{ time: 8200, value: 0.05, hadRecentInput: false },
];
let windows = 0;
let current = 0;
let windowStart = 0;
let lastTime = -Infinity;
let cls = 0;
let total = 0;
for (const shift of shifts) {
if (shift.hadRecentInput) continue;
total += shift.value;
const sameWindow = shift.time - lastTime < 1000 && shift.time - windowStart < 5000;
if (sameWindow) {
current += shift.value;
} else {
windows += 1;
current = shift.value;
windowStart = shift.time;
}
lastTime = shift.time;
cls = Math.max(cls, current);
}
console.log(windows);
console.log(cls.toFixed(2));
console.log(total.toFixed(2));
console.log(cls <= 0.1 ? "good" : cls <= 0.25 ? "needs improvement" : "poor");