Loading problem...
A manufacturing observability system records process lifecycle events from multiple machines.
Table: activity
Data guarantees:
Metric definitions:
Task: Return the average process duration per machine.
Output requirements:
Supported submission environments:
activity:
| machine_id | process_id | activity_type | timestamp |
|------------|------------|---------------|-----------|
| 0 | 0 | start | 0.712 |
| 0 | 0 | end | 1.520 |
| 0 | 1 | start | 3.140 |
| 0 | 1 | end | 4.120 |
| 1 | 0 | start | 0.550 |
| 1 | 0 | end | 1.550 |
| 1 | 1 | start | 0.430 |
| 1 | 1 | end | 1.420 |
| 2 | 0 | start | 4.100 |
| 2 | 0 | end | 4.512 |
| 2 | 1 | start | 2.500 |
| 2 | 1 | end | 5.000 |[
{"machine_id":0,"processing_time":0.894},
{"machine_id":1,"processing_time":0.995},
{"machine_id":2,"processing_time":1.456}
]For each machine, compute duration per process and then take the arithmetic mean of those durations.
activity:
| machine_id | process_id | activity_type | timestamp |
|------------|------------|---------------|-----------|
| 5 | 11 | start | 10.100 |
| 5 | 11 | end | 11.000 |
| 5 | 12 | start | 12.000 |
| 5 | 12 | end | 13.500 |
| 5 | 13 | start | 15.250 |
| 5 | 13 | end | 15.750 |[
{"machine_id":5,"processing_time":0.967}
]Durations are [0.900, 1.500, 0.500], whose average is 0.966666..., rounded to 0.967.
activity:
| machine_id | process_id | activity_type | timestamp |
|------------|------------|---------------|-----------|
| 3 | 30 | start | 1.000 |
| 3 | 30 | end | 2.000 |
| 7 | 70 | start | 1.100 |
| 7 | 70 | end | 1.700 |
| 7 | 71 | start | 2.400 |
| 7 | 71 | end | 4.000 |[
{"machine_id":3,"processing_time":1.0},
{"machine_id":7,"processing_time":1.1}
]Machine 3 has one process with duration 1.0. Machine 7 has durations 0.6 and 1.6, so average is 1.1.
Constraints