As a dad, I frequently to play math quiz with my daughter. Bu I'm too lazy to frequently to create math questions. This' reason why I create this lib/api/web, that I can help me to generate questions. This repository will evolue frequently, I think, to support more topic.
Install library:
go get -u github.com/ledongthuc/mathgen
Usage:
questionAndAnswers, _ := mathgen.AddIntegerN(3, 20)
fmt.Println("Addends:", questionAndAnswers.Addends)
fmt.Println("Sum:", questionAndAnswers.Sum)
fmt.Println("Format:", questionAndAnswers.String())
More detail supported functions is cover at: https://godoc.org/github.com/ledongthuc/mathgen
Start with docker:
docker run -p 8080:8080 ledongthuc/mathgen-web:latest
Start from source code:
make clean; make test; make run;
POST http://localhost:8080/api/addition/generate
Request:
{
"number_of_addends 2,
"max_sum": 10
}
Response:
{
"addends": [
3,
4
],
"sum": 7,
"question": "3 + 4 = ",
"result": "3 + 4 = 7"
}
POST http://localhost:8080/api/subtraction/generate
Request:
{
"max_minuend": 20,
"number_of_subtrahends": 1
}
Response:
{
"minuend": 9,
"subtrahends": [
5
],
"difference": 4,
"question": "9 - 5 = ",
"result": "9 - 5 = 4"
}
Local: http://localhost:8080
Free site: https://mathgen.thuc.space