(customers: Vec<Vec<i32>>)
| 1 | pub fn average_waiting_time(customers: Vec<Vec<i32>>) -> f64 { |
| 2 | let mut time = 0f64; |
| 3 | let mut sum = 0f64; |
| 4 | for customer in &customers { |
| 5 | if customer[0] as f64 >= time { |
| 6 | sum += customer[1] as f64; |
| 7 | time = (customer[0] + customer[1]) as f64; |
| 8 | } else { |
| 9 | sum += time + (customer[1] - customer[0]) as f64; |
| 10 | time += customer[1] as f64; |
| 11 | } |
| 12 | } |
| 13 | sum as f64 / customers.len() as f64 |
| 14 | } |
| 15 | |
| 16 | fn main() { |
| 17 | println!("{:?}", average_waiting_time(vec![vec![1,2], vec![2,5], vec![4,3]])); |
nothing calls this directly
no outgoing calls
no test coverage detected