summary refs log tree commit diff stats
path: root/rust
diff options
context:
space:
mode:
Diffstat (limited to 'rust')
-rw-r--r--rust/assembly-line/Cargo.lock5
-rw-r--r--rust/assembly-line/src/lib.rs15
-rw-r--r--rust/assembly-line/tests/assembly-line.rs9
3 files changed, 15 insertions, 14 deletions
diff --git a/rust/assembly-line/Cargo.lock b/rust/assembly-line/Cargo.lock
new file mode 100644
index 0000000..69406c1
--- /dev/null
+++ b/rust/assembly-line/Cargo.lock
@@ -0,0 +1,5 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "assembly-line"
+version = "0.1.0"
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
 }
diff --git a/rust/assembly-line/tests/assembly-line.rs b/rust/assembly-line/tests/assembly-line.rs
index 746a914..6da6cdd 100644
--- a/rust/assembly-line/tests/assembly-line.rs
+++ b/rust/assembly-line/tests/assembly-line.rs
@@ -14,55 +14,46 @@ fn production_rate_per_hour_at_speed_zero() {
     process_rate_per_hour(0, 0.0);
 }
 
-#[ignore]
 #[test]
 fn production_rate_per_hour_at_speed_one() {
     process_rate_per_hour(1, 221.0);
 }
 
-#[ignore]
 #[test]
 fn production_rate_per_hour_at_speed_four() {
     process_rate_per_hour(4, 884.0);
 }
 
-#[ignore]
 #[test]
 fn production_rate_per_hour_at_speed_seven() {
     process_rate_per_hour(7, 1392.3);
 }
 
-#[ignore]
 #[test]
 fn production_rate_per_hour_at_speed_nine() {
     process_rate_per_hour(9, 1531.53);
 }
 
-#[ignore]
 #[test]
 fn production_rate_per_minute_at_speed_zero() {
     process_rate_per_minute(0, 0);
 }
 
-#[ignore]
 #[test]
 fn production_rate_per_minute_at_speed_one() {
     process_rate_per_minute(1, 3);
 }
 
-#[ignore]
 #[test]
 fn production_rate_per_minute_at_speed_five() {
     process_rate_per_minute(5, 16);
 }
 
-#[ignore]
 #[test]
 fn production_rate_per_minute_at_speed_eight() {
     process_rate_per_minute(8, 26);
 }
 
-#[ignore]
 #[test]
 fn production_rate_per_minute_at_speed_ten() {
     process_rate_per_minute(10, 28);