diff options
author | Andinus <andinus@nand.sh> | 2021-09-11 19:36:29 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2021-09-11 19:36:29 +0530 |
commit | 50bf972e9374c0f433b53ed80805ba5cbfb2a924 (patch) | |
tree | 8f0bac15314536cb4f95dad8236c35fdd9797fd0 /rust/assembly-line/src | |
parent | deeb163b901cac7169c2e0363bfff8e44d264c8c (diff) | |
download | exercism-50bf972e9374c0f433b53ed80805ba5cbfb2a924.tar.gz |
Rust: Assembly Line: Add solution
Diffstat (limited to 'rust/assembly-line/src')
-rw-r--r-- | rust/assembly-line/src/lib.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/rust/assembly-line/src/lib.rs b/rust/assembly-line/src/lib.rs index de29988..4d8d248 100644 --- a/rust/assembly-line/src/lib.rs +++ b/rust/assembly-line/src/lib.rs @@ -1,11 +1,16 @@ -// This stub file contains items which aren't used yet; feel free to remove this module attribute -// to enable stricter warnings. -#![allow(unused)] +const CARS_PER_HR: u32 = 221; pub fn production_rate_per_hour(speed: u8) -> f64 { - unimplemented!("calculate hourly production rate at speed: {}", speed) + 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 { - unimplemented!("calculate the amount of working items at speed: {}", speed) + (production_rate_per_hour(speed) / 60.0).floor() as u32 } |