20 lines
338 B
Go
20 lines
338 B
Go
|
package util
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"math/rand"
|
||
|
)
|
||
|
|
||
|
func GenerateCalculation(correct bool) string {
|
||
|
firstNum := rand.Intn(100)
|
||
|
secondNum := rand.Intn(100)
|
||
|
|
||
|
solution := firstNum + secondNum
|
||
|
|
||
|
for !correct && solution == firstNum+secondNum {
|
||
|
solution = rand.Intn(150)
|
||
|
}
|
||
|
|
||
|
return fmt.Sprintf("%d + %d = %d", firstNum, secondNum, solution)
|
||
|
}
|