THINK FIRST·CODE LATER

← All labs

DORA metrics from a deployment log

Problem

Compute the four DORA metrics for StudyBuddy from its deployment log.

Input: first line days n — the length of the period in days and the number of deployments. Then n lines, each:

leadTimeHours result [restoreMinutes]

where result is OK or FAIL; a FAIL line has a third number, the minutes needed to restore service.

Print:

Deployments: n
Deployment frequency: X per week
Average lead time: Y hours
Change failure rate: Z%
Mean time to restore: W minutes
  • frequency = n * 7 / days, two decimals;
  • average lead time: two decimals (0.00 if n is 0);
  • change failure rate: failures × 100 / n, one decimal (0.0 if n is 0);
  • mean time to restore: average of the restore minutes of the failures, one decimal, or n/a if there were no failures.

Input:

14 5
2 OK
4 OK
1 FAIL 90
3 OK
5 FAIL 30

Output:

Deployments: 5
Deployment frequency: 2.50 per week
Average lead time: 3.00 hours
Change failure rate: 40.0%
Mean time to restore: 60.0 minutes

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.