From d66e9ea79894bd8f58c70319312600542f6f168f Mon Sep 17 00:00:00 2001 From: Mu-An Chiou Date: Mon, 29 Jun 2020 02:59:59 -0400 Subject: [PATCH] Invalid guess should not count as an attempt --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 019cad2..4f70839 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,8 +25,7 @@ For example, with an answer of 7130, a guess of 3610 will receive 1A2B. // println!("-----------------------------------------------------------------------"); loop { - tries = tries + 1; - println!("> ({}) Enter a 4-digit number:", tries); + println!("> ({}) Guess a 4-digit number:", tries); let mut guess = String::new(); io::stdin() @@ -56,6 +55,7 @@ For example, with an answer of 7130, a guess of 3610 will receive 1A2B. continue; }, Ordering::Equal => { + tries = tries + 1; let result = check_answer(&answer, &guess); if result == "4A0B" { println!("You got it! 👾");