Skip to content
Snippets Groups Projects
Commit 19df3cce authored by Henrik Tjäder's avatar Henrik Tjäder
Browse files

Print the last 3 attempts backwards

parent b162b995
No related branches found
No related tags found
No related merge requests found
...@@ -39,13 +39,15 @@ fn main() { ...@@ -39,13 +39,15 @@ fn main() {
Ordering::Equal => { Ordering::Equal => {
println!("You win!"); println!("You win!");
println!("Total number of attempts: {}", tries_counter); println!("Total number of attempts: {}", tries_counter);
println!("First print:"); println!("Last entry first, maximum 3:");
for x in attempt_history.iter() { for (i, x) in attempt_history.iter().rev().enumerate() {
println!("{:?}", x); println!("{:?}", x);
// Only print the 3 last (see .rev() above)
if i >= 2 {
break;
} }
println!("\nSecond print:");
for x in attempt_history.iter() {
println!("{:?}", x);
} }
break; break;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment