paper

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package paper is the key of a task from the learner's paper: the solver, which computes the answer of arithmetic and of an equation in one unknown from the formula AI read of the statement, exactly and without Starlark or the network; the rules an answer of AI holds before it is a key; and the item and the values by which the package observation judges the reading of the work against the key, as on a task of a module.

Solve gives the solver's answer or why it does not take the formula, Breach the rule an answer of AI breaks, Key the key of an attempt with its provenance, Items the task's one item by the answer of its key, and Brought and BroughtValue the values read brought to it. The formula, the solver, the answer, the key and the verdict are those of spec's contracts, whose test vectors the package passes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Brought

Brought gives a copy of an observation with each value brought to the key, so that the join of two readings compares x = 4 and 4 as the same value.

func BroughtValue

func BroughtValue(answer *paperv1.Answer, value string) string

BroughtValue gives a value read brought to the key: x = 4 as 4 when the key's unknown is x, and (C) as C of a choice; any other value as it is.

func Items

func Items(answer *paperv1.Answer) []formatv0.Item

Items gives the task's one item by the answer of its key: one answer slot bound anywhere, with the check kind number or choice written by hand, and no trap values. With them, the package observation joins and judges the readings of the work as on a task of a module, once Brought has brought their values to the key.

An answer of no kind, nil too, is a task with no key, and gives no item: no check can be written of it, and the package observation judges none. Its item is unchecked, which the caller gives it without the package observation.

func Key

func Key(solved *paperv1.Number, ofAI *paperv1.Answer) *paperv1.TaskKey

Key gives the key of one task of an attempt, with no statement, which the caller sets: the solver's answer with the provenance of the solver, when there is one, or else the answer of AI with the provenance of AI when it breaks no rule. With neither the key has no answer and no provenance, which says the task has none.

Types

type Reason

type Reason string

Reason is why the solver does not take a formula, as the contracts text names it.

const (
	Syntax              Reason = "syntax"                // not of the grammar, too long, a number of more than 15 digits or an exponent above 10
	TwoUnknowns         Reason = "two_unknowns"          // two letters or more
	UnknownInExpression Reason = "unknown_in_expression" // an expression with an unknown
	NoUnknown           Reason = "no_unknown"            // an equation with no unknown
	NotLinear           Reason = "not_linear"            // the unknown times itself, in a divisor, or to 2 or more
	DivisionByZero      Reason = "division_by_zero"      // a division by zero
	TooLarge            Reason = "too_large"             // a part of more than 100 digits on the way, or an answer longer than 16 characters
	NoRoot              Reason = "no_root"               // an equation no number solves
	EveryRoot           Reason = "every_root"            // an equation every number solves
)

The reasons, in the order the solver names the first that applies: syntax, then the letters, then those of the operations as they are done, then the root, and last too_large of the answer.

func Solve

func Solve(formula string) (*paperv1.Number, Reason)

Solve gives the answer of the solver on a formula, a Number with its value and the letter of an equation's unknown, or the reason it does not take it.

type Rule

type Rule string

Rule is a rule of an answer of AI that the answer breaks, as the vectors name it.

const (
	NoKind       Rule = "no_kind"       // neither a number nor a choice
	Value        Rule = "value"         // a number not in the notation of number, or longer than 16 characters
	UnitsEmpty   Rule = "units_empty"   // a unit empty once it went through the steps of units
	UnitsSame    Rule = "units_same"    // two units the same then
	Unknown      Rule = "unknown"       // an unknown that is not one letter from a to z
	OptionsCount Rule = "options_count" // fewer than 2 options, or more than 10
	OptionLength Rule = "option_length" // a label of fewer than 1 character or more than 16
	OptionsSame  Rule = "options_same"  // a label empty, or two the same, once normalized as a choice
	ChoiceKey    Rule = "choice_key"    // a key that is none of the options as written
)

The rules of an answer, in the order Breach checks them.

func Breach

func Breach(answer *paperv1.Answer) Rule

Breach gives the first rule of an answer of AI that it breaks, or "" when it is an answer, which a key may hold.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL