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(())