Skip to content

serkanalgur/kids-math-generator-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kids-math-generator-go

Go Reference Go Report Card

A Go port of the kids-math-generator TypeScript package to generate math questions for grades 1–6.

Features

  • Deterministic option via seed
  • Grade-appropriate math questions (grades 1–6)
  • Difficulty levels: easy, medium, hard, veryHard
  • Mixed-operation questions and missing-operand transformations

Quick usage

package main

import (
	"fmt"
	"github.com/serkanalgur/kids-math-generator-go/kidsmath"
)

func main() {
	q := kidsmath.GenerateQuestion(kidsmath.Options{Grade: 3, Operation: kidsmath.OpMul, Difficulty: kidsmath.DifficultyEasy, Seed: 42})
	fmt.Println(q.Text, "→", q.Answer)
}

Run tests:

go test ./...

Install and run the example CLI:

go install github.com/serkanalgur/kids-math-generator-go/cmd/kids-math-gen@latest
kids-math-gen -grade=3 -op=mul -seed=42

Examples from code:

q := kidsmath.GenerateQuestion(kidsmath.Options{Grade: 3, Operation: kidsmath.OpMul, Difficulty: kidsmath.DifficultyEasy, Seed: intPtr(42)})
fmt.Println(q.Text, "→", q.Answer)

Helper functions:

  • MakeRng(seed *int) — create deterministic RNG
  • MakeMissingOperandQuestion(q, rng) — convert a question into missing operand form

Packages

 
 
 

Contributors

Languages