From a470e883af95205b9faf3702f750bf6a661f5306 Mon Sep 17 00:00:00 2001 From: Martin HART Date: Sat, 31 Oct 2020 19:23:04 +0100 Subject: [PATCH] fix iteration bug --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3733ac9..211ab08 100644 --- a/src/main.rs +++ b/src/main.rs @@ -218,9 +218,9 @@ fn main() -> Result<(), Box> { let mut hash: HashMap = HashMap::new(); create_hash_map(&robot_pool, &mut hash); - let mut piouff: u32 = 0; - while piouff != robot_pool.len() as u32 { - for r in robot_pool { + loop { + let mut piouff: u32 = 0; + for mut r in robot_pool { if robot::is_piouff(&r) { piouff += 1; } else { @@ -229,6 +229,9 @@ fn main() -> Result<(), Box> { check_map(&r, &world)?; check_collisions(&r, &hash)?; } + if piouff == robot_pool.len() as u32 { + break; + } } Ok(())