#152·learngo

Should it be a max and not min?

Author: bkalchoCreated Apr 17, 2023Updated Apr 17, 2023

In this part of the code, you refer to the boundary for rand.Intn should be min. If it is min then the max generated number will be from [0, min) + 1, meaning that the guess which is > min will not be taken into count. My understanding is it should be:

max := guess
if guess1 > max {
  max = guess1
}

This way we will evaluate against both guess and guess1.

https://github.com/inancgumus/learngo/blob/e366d1a364eba61a08f84a17ef6dbf60818aa144/13-loops/exercises/08-lucky-number-exercises/03-double-guesses/solution/main.go#L62