Comment code and remove unnecessary code.

This commit is contained in:
Nicolás A. Ortega Froysa 2022-06-30 19:06:55 +02:00
parent cd8f4319ab
commit 3e2a3c385c

View File

@ -26,6 +26,8 @@ extern crate rand;
fn main() { fn main() {
let size = 100; let size = 100;
// initialize the boxes with randomly assigned numbers
let mut boxes:Vec<u32> = Vec::with_capacity(size as usize); let mut boxes:Vec<u32> = Vec::with_capacity(size as usize);
{ {
@ -39,6 +41,7 @@ fn main() {
} }
} }
// have prisoners find their number
let mut all_found = true; let mut all_found = true;
for i in 0..size for i in 0..size
{ {
@ -54,10 +57,6 @@ fn main() {
else else
{ {
next_box = boxes[next_box] as usize; next_box = boxes[next_box] as usize;
if next_box == i as usize
{
break;
}
} }
} }
if !found if !found
@ -66,6 +65,7 @@ fn main() {
} }
} }
// print result
if all_found if all_found
{ {
println!("All prisoners found their numbers!"); println!("All prisoners found their numbers!");