summary refs log tree commit diff stats
path: root/rust/assembly-line/src/lib.rs
blob: 4d8d248568a5cba8ebaa83dd562b15a275e8dcf3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const CARS_PER_HR: u32 = 221;

pub fn production_rate_per_hour(speed: u8) -> f64 {
    let mut cars: f64 = ((speed as u32) * CARS_PER_HR) as f64;

    match speed {
        5..=8 => cars *= 0.90,
        9 | 10 => cars *= 0.77,
        _ => {},
    }
    cars
}

pub fn working_items_per_minute(speed: u8) -> u32 {
    (production_rate_per_hour(speed) / 60.0).floor() as u32
}