summary refs log tree commit diff stats
path: root/rust/assembly-line/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/assembly-line/src/lib.rs')
-rw-r--r--rust/assembly-line/src/lib.rs15
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
 }