From 3e2a3c385ca39a9fe39d5acbacbdc55599abb2b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Thu, 30 Jun 2022 19:06:55 +0200 Subject: [PATCH] Comment code and remove unnecessary code. --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 54f00fd..cd57182 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,6 +26,8 @@ extern crate rand; fn main() { let size = 100; + + // initialize the boxes with randomly assigned numbers let mut boxes:Vec = Vec::with_capacity(size as usize); { @@ -39,6 +41,7 @@ fn main() { } } + // have prisoners find their number let mut all_found = true; for i in 0..size { @@ -54,10 +57,6 @@ fn main() { else { next_box = boxes[next_box] as usize; - if next_box == i as usize - { - break; - } } } if !found @@ -66,6 +65,7 @@ fn main() { } } + // print result if all_found { println!("All prisoners found their numbers!");