From 5ba12125ed2eccb914e308fd335c715bbe759e26 Mon Sep 17 00:00:00 2001 From: AminBhr <83537913+AminBhr@users.noreply.github.com> Date: Mon, 27 Sep 2021 02:20:59 +0330 Subject: [PATCH] Update: change the solution to follow instrucion The exercise restriction says, "Do not make the game too easy. Only adjust the difficulty if the guess is above 10." --- .../06-dynamic-difficulty/solution/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/13-loops/exercises/08-lucky-number-exercises/06-dynamic-difficulty/solution/main.go b/13-loops/exercises/08-lucky-number-exercises/06-dynamic-difficulty/solution/main.go index a4db180..9ffce6a 100644 --- a/13-loops/exercises/08-lucky-number-exercises/06-dynamic-difficulty/solution/main.go +++ b/13-loops/exercises/08-lucky-number-exercises/06-dynamic-difficulty/solution/main.go @@ -49,8 +49,13 @@ func main() { fmt.Println("Please pick a positive number.") return } + + var balancer int + if guess > 10 { + balancer = guess / 4 + } - for turn := maxTurns + guess/4; turn > 0; turn-- { + for turn := maxTurns + balancer; turn > 0; turn-- { n := rand.Intn(guess) + 1 if n == guess {