From 31b95ad12e424f197268185c6b68863880042f4d Mon Sep 17 00:00:00 2001 From: deadvey Date: Sun, 5 Jan 2025 03:14:15 +0000 Subject: [PATCH] bug fix for prophecies --- prophecies/src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/prophecies/src/main.rs b/prophecies/src/main.rs index df18af0..f7eb576 100644 --- a/prophecies/src/main.rs +++ b/prophecies/src/main.rs @@ -19,9 +19,14 @@ fn main() -> io::Result<()> { let lines_in_string = split_string.len(); // Iterate for "number_of_lines" and each time pick a random line in the file + let mut previous_line_index = 0; for _i in 0..number_of_lines { let line_index = rand::thread_rng().gen_range(0..lines_in_string); // Pick random line + if split_string[previous_line_index] == split_string[line_index] { + continue; + } println!("{}",split_string[line_index]); // Print the random line + previous_line_index = line_index; } Ok(())