refactor: lucky number exercises

* guess < 0 doesn't check for definitive positivity
* n := rand.Intn(guess + 1) may pick 0, a non positive integer
* remove: redundant parentheses from the loop in 06-dynamic-difficulty
This commit is contained in:
Paul Waldmann
2021-01-10 17:34:48 +01:00
committed by GitHub
parent 8a5d1c6704
commit a3fc5396bf
7 changed files with 15 additions and 15 deletions

View File

@@ -53,13 +53,13 @@ func main() {
return
}
if guess < 0 {
if guess <= 0 {
fmt.Println("Please pick a positive number.")
return
}
for turn := 1; turn <= maxTurns; turn++ {
n := rand.Intn(guess + 1)
n := rand.Intn(guess) + 1
if verbose {
fmt.Printf("%d ", n)