Problems › TypeScript › production
Overall equipment effectiveness
OEE multiplies three percentages together into one number that plant managers compare across lines.
- Availability, performance and quality are each a percentage from 0 to 100.
- The score is the three multiplied and brought back to a percentage, rounded half up.
- Anything outside 0 to 100 is clamped into range before the sum.
oeeScore(availability: int, performance: int, quality: int) → int
Where you start
function oeeScore(availability: number, performance: number, quality: number): number {
}
Worked examples
| Call | Result |
|---|---|
oeeScore(90, 95, 99) | 85 |
oeeScore(100, 100, 100) | 100 |
oeeScore(0, 100, 100) | 0 |
oeeScore(150, 100, 100) | 100 |
Hint
Clamp all three first, then multiply and divide by 10000 — adding 5000 before the divide rounds it.
Reference solution in TypeScript
function oeeScore(availability: number, performance: number, quality: number): number {
const c = (v: number) => Math.max(0, Math.min(100, v));
const n = c(availability) * c(performance) * c(quality);
return Math.floor((n + 5000) / 10000);
}