math-exercises 3.0.146 → 3.0.148

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/lib/exercises/math/calcul/arithmetics/findLeftoverInContext.js +1 -1
  2. package/lib/exercises/math/calcul/mentalCaluls/index.d.ts +1 -0
  3. package/lib/exercises/math/calcul/mentalCaluls/index.d.ts.map +1 -1
  4. package/lib/exercises/math/calcul/mentalCaluls/index.js +1 -0
  5. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.d.ts.map +1 -1
  6. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.js +28 -4
  7. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSubNoRelative.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSubNoRelative.js +50 -23
  9. package/lib/exercises/math/calcul/mentalCaluls/mentalApplyPercentageEvolution.d.ts +9 -0
  10. package/lib/exercises/math/calcul/mentalCaluls/mentalApplyPercentageEvolution.d.ts.map +1 -0
  11. package/lib/exercises/math/calcul/mentalCaluls/mentalApplyPercentageEvolution.js +423 -0
  12. package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplications.d.ts.map +1 -1
  13. package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplications.js +48 -24
  14. package/lib/exercises/math/calcul/mentalCaluls/mentalPercentage.d.ts.map +1 -1
  15. package/lib/exercises/math/calcul/mentalCaluls/mentalPercentage.js +236 -22
  16. package/lib/exercises/math/calcul/operations/operationsPriorities.d.ts.map +1 -1
  17. package/lib/exercises/math/calcul/operations/operationsPriorities.js +48 -20
  18. package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesis.d.ts.map +1 -1
  19. package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesis.js +47 -19
  20. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts.map +1 -1
  21. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +26 -6
  22. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.d.ts.map +1 -1
  23. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.js +92 -16
  24. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.d.ts.map +1 -1
  25. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.js +1 -0
  26. package/lib/exercises/math/conversion/volumeCapacityConversion.d.ts.map +1 -1
  27. package/lib/exercises/math/conversion/volumeCapacityConversion.js +171 -0
  28. package/lib/exercises/math/dataRepresentations/barChartReading.d.ts.map +1 -1
  29. package/lib/exercises/math/dataRepresentations/barChartReading.js +17 -8
  30. package/lib/exercises/math/dataRepresentations/functionGraphReading.d.ts.map +1 -1
  31. package/lib/exercises/math/dataRepresentations/functionGraphReading.js +94 -8
  32. package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts +6 -1
  33. package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts.map +1 -1
  34. package/lib/exercises/math/functions/affines/affineExpressionReading.js +166 -52
  35. package/lib/exercises/math/functions/affines/drawAffineFromLitExp.d.ts +5 -1
  36. package/lib/exercises/math/functions/affines/drawAffineFromLitExp.d.ts.map +1 -1
  37. package/lib/exercises/math/functions/affines/drawAffineFromLitExp.js +59 -17
  38. package/lib/exercises/math/functions/basics/graphicInequation.js +1 -1
  39. package/lib/exercises/math/functions/index.d.ts +1 -0
  40. package/lib/exercises/math/functions/index.d.ts.map +1 -1
  41. package/lib/exercises/math/functions/index.js +1 -0
  42. package/lib/exercises/math/functions/linear/index.d.ts +3 -0
  43. package/lib/exercises/math/functions/linear/index.d.ts.map +1 -0
  44. package/lib/exercises/math/functions/linear/index.js +2 -0
  45. package/lib/exercises/math/functions/linear/linearFromExercise.d.ts +9 -0
  46. package/lib/exercises/math/functions/linear/linearFromExercise.d.ts.map +1 -0
  47. package/lib/exercises/math/functions/linear/linearFromExercise.js +354 -0
  48. package/lib/exercises/math/functions/linear/linearFromPercentageEvolution.d.ts +8 -0
  49. package/lib/exercises/math/functions/linear/linearFromPercentageEvolution.d.ts.map +1 -0
  50. package/lib/exercises/math/functions/linear/linearFromPercentageEvolution.js +233 -0
  51. package/lib/exercises/math/functions/trinoms/devForm/coefficientsIdentification.d.ts.map +1 -1
  52. package/lib/exercises/math/functions/trinoms/devForm/coefficientsIdentification.js +2 -5
  53. package/lib/exercises/math/geometry/thales/thalesIsParallelFromAbstractFormula.d.ts +22 -0
  54. package/lib/exercises/math/geometry/thales/thalesIsParallelFromAbstractFormula.d.ts.map +1 -0
  55. package/lib/exercises/math/geometry/thales/thalesIsParallelFromAbstractFormula.js +647 -0
  56. package/lib/exercises/math/geometry/thales/thalesPickFormulaForIsParallel.d.ts +23 -0
  57. package/lib/exercises/math/geometry/thales/thalesPickFormulaForIsParallel.d.ts.map +1 -0
  58. package/lib/exercises/math/geometry/thales/thalesPickFormulaForIsParallel.js +540 -0
  59. package/lib/exercises/math/spaceGeometry/basis/spaceCoordinatesInPrism.d.ts.map +1 -1
  60. package/lib/exercises/math/spaceGeometry/basis/spaceCoordinatesInPrism.js +75 -6
  61. package/lib/index.d.ts +22 -3
  62. package/lib/index.d.ts.map +1 -1
  63. package/lib/tree/nodes/equations/notEqualNode.d.ts +35 -0
  64. package/lib/tree/nodes/equations/notEqualNode.d.ts.map +1 -0
  65. package/lib/tree/nodes/equations/notEqualNode.js +84 -0
  66. package/lib/tree/utilities/nodeSimplifier.d.ts +16 -0
  67. package/lib/tree/utilities/nodeSimplifier.d.ts.map +1 -0
  68. package/lib/tree/utilities/nodeSimplifier.js +283 -0
  69. package/package.json +1 -1
package/lib/index.d.ts CHANGED
@@ -198,6 +198,10 @@ declare const mathExercises: (Exercise<{
198
198
  }, {
199
199
  quantityTypes: string[];
200
200
  }> | Exercise<{
201
+ rand: number;
202
+ a: number;
203
+ b: number;
204
+ }, Record<string, string | boolean | string[]>> | Exercise<{
201
205
  type: number;
202
206
  a: number;
203
207
  b: number;
@@ -1045,9 +1049,12 @@ declare const mathExercises: (Exercise<{
1045
1049
  b: number;
1046
1050
  askingPositive: boolean;
1047
1051
  }, Record<string, string | boolean | string[]>> | Exercise<{
1052
+ isLinear: boolean;
1048
1053
  b: number;
1049
1054
  secondPoint: number[];
1050
- }, Record<string, string | boolean | string[]>> | Exercise<{
1055
+ }, {
1056
+ isLinear: boolean;
1057
+ }> | Exercise<{
1051
1058
  b: number;
1052
1059
  secondPoint: number[];
1053
1060
  }, Record<string, string | boolean | string[]>> | Exercise<{
@@ -1084,7 +1091,9 @@ declare const mathExercises: (Exercise<{
1084
1091
  correctA: number;
1085
1092
  correctB: number;
1086
1093
  nameFunc: string;
1087
- }, Record<string, string | boolean | string[]>> | Exercise<{
1094
+ }, {
1095
+ isLinear: boolean;
1096
+ }> | Exercise<{
1088
1097
  items: {
1089
1098
  fName: string;
1090
1099
  tex: string;
@@ -1593,6 +1602,13 @@ declare const mathExercises: (Exercise<{
1593
1602
  tex: string;
1594
1603
  isValid: boolean;
1595
1604
  }[];
1605
+ }, Record<string, string | boolean | string[]>> | Exercise<{
1606
+ situationIndex: number;
1607
+ x1: number;
1608
+ y1: number;
1609
+ }, Record<string, string | boolean | string[]>> | Exercise<{
1610
+ situationIndex: number;
1611
+ numP: number;
1596
1612
  }, Record<string, string | boolean | string[]>> | Exercise<{
1597
1613
  coin: boolean;
1598
1614
  radius: number;
@@ -3575,9 +3591,12 @@ declare const pcExercises: (Exercise<{
3575
3591
  equaDiffIdentifiers: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
3576
3592
  isSolution: boolean;
3577
3593
  }, Record<string, string | boolean | string[]>> | Exercise<{
3594
+ isLinear: boolean;
3578
3595
  b: number;
3579
3596
  secondPoint: number[];
3580
- }, Record<string, string | boolean | string[]>> | Exercise<{
3597
+ }, {
3598
+ isLinear: boolean;
3599
+ }> | Exercise<{
3581
3600
  tenthPower: number;
3582
3601
  }, Record<string, string | boolean | string[]>> | Exercise<{
3583
3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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { AlgebraicNode } from "../algebraicNode.js";
2
+ import { NodeIds, NodeOptions, NodeType } from "../node.js";
3
+ import { NodeIdentifiers } from "../nodeConstructor.js";
4
+ export declare const notEqual: (a: AlgebraicNode | number | string, b: AlgebraicNode | number | string) => NotEqualNode;
5
+ export type NotEqualNodeIdentifiers = {
6
+ id: NodeIds.notEqual;
7
+ leftChild: NodeIdentifiers;
8
+ rightChild: NodeIdentifiers;
9
+ opts?: NodeOptions;
10
+ };
11
+ export declare abstract class NotEqualNodeConstructor {
12
+ static fromIdentifiers(identifiers: NotEqualNodeIdentifiers): NotEqualNode;
13
+ }
14
+ export declare const isNotEqualNode: (node: AlgebraicNode) => node is NotEqualNode;
15
+ export declare class NotEqualNode implements AlgebraicNode {
16
+ leftChild: AlgebraicNode;
17
+ rightChild: AlgebraicNode;
18
+ opts?: NodeOptions;
19
+ type: NodeType;
20
+ isNumeric: boolean;
21
+ constructor(leftChild: AlgebraicNode, rightChild: AlgebraicNode, opts?: NodeOptions);
22
+ toIdentifiers(): NotEqualNodeIdentifiers;
23
+ toEquivalentNodes(opts?: NodeOptions): AlgebraicNode[];
24
+ toAllValidTexs(opts?: NodeOptions): string[];
25
+ toMathString(): string;
26
+ toTex(): string;
27
+ shuffle(): NotEqualNode;
28
+ reverse(): NotEqualNode;
29
+ evaluate(): number;
30
+ toDetailedEvaluation(): AlgebraicNode;
31
+ simplify(): AlgebraicNode;
32
+ equals(): boolean;
33
+ derivative(): AlgebraicNode;
34
+ }
35
+ //# sourceMappingURL=notEqualNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notEqualNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/equations/notEqualNode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAkB,MAAM,uBAAuB,CAAC;AAExE,eAAO,MAAM,QAAQ,GACnB,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,EAClC,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,iBAOnC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC;IACrB,SAAS,EAAE,eAAe,CAAC;IAC3B,UAAU,EAAE,eAAe,CAAC;IAC5B,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,CAAC;AAEF,8BAAsB,uBAAuB;IAC3C,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,uBAAuB,GAAG,YAAY;CAO3E;AAED,eAAO,MAAM,cAAc,GAAI,MAAM,aAAa,KAAG,IAAI,IAAI,YACzB,CAAC;AAErC,qBAAa,YAAa,YAAW,aAAa;IAChD,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IASpB,aAAa,IAAI,uBAAuB;IAQxC,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IAmBpC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAM5C,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAIf,OAAO;IAIP,OAAO;IAIP,QAAQ,IAAI,MAAM;IAGlB,oBAAoB,IAAI,aAAa;IAGrC,QAAQ,IAAI,aAAa;IAGzB,MAAM,IAAI,OAAO;IAGjB,UAAU,IAAI,aAAa;CAG5B"}
@@ -0,0 +1,84 @@
1
+ // import { equal } from "mathjs";
2
+ import { coinFlip } from "../../../utils/alea/coinFlip.js";
3
+ import { NodeIds, NodeType } from "../node.js";
4
+ import { reifyAlgebraic } from "../nodeConstructor.js";
5
+ export const notEqual = (a, b) => {
6
+ const nodeA = typeof a === "number" ? a.toTree() : typeof a === "string" ? a.toTree() : a;
7
+ const nodeB = typeof b === "number" ? b.toTree() : typeof b === "string" ? b.toTree() : b;
8
+ return new NotEqualNode(nodeA, nodeB);
9
+ };
10
+ export class NotEqualNodeConstructor {
11
+ static fromIdentifiers(identifiers) {
12
+ return new NotEqualNode(reifyAlgebraic(identifiers.leftChild), reifyAlgebraic(identifiers.rightChild), identifiers.opts);
13
+ }
14
+ }
15
+ export const isNotEqualNode = (node) => node.type === NodeType.notequality;
16
+ export class NotEqualNode {
17
+ leftChild;
18
+ rightChild;
19
+ opts;
20
+ type;
21
+ isNumeric;
22
+ constructor(leftChild, rightChild, opts) {
23
+ this.leftChild = leftChild;
24
+ this.rightChild = rightChild;
25
+ this.type = NodeType.equality;
26
+ this.opts = opts;
27
+ this.isNumeric = false;
28
+ }
29
+ toIdentifiers() {
30
+ return {
31
+ id: NodeIds.notEqual,
32
+ leftChild: this.leftChild.toIdentifiers(),
33
+ rightChild: this.rightChild.toIdentifiers(),
34
+ opts: this.opts,
35
+ };
36
+ }
37
+ toEquivalentNodes(opts) {
38
+ const options = opts ?? this.opts;
39
+ const res = [];
40
+ const rightNodes = this.rightChild.toEquivalentNodes(options);
41
+ if (options?.allowRawRightChildAsSolution) {
42
+ res.push(...rightNodes);
43
+ }
44
+ const leftNodes = this.leftChild.toEquivalentNodes(options);
45
+ rightNodes.forEach((rightNode) => {
46
+ leftNodes.forEach((leftNode) => {
47
+ res.push(new NotEqualNode(leftNode, rightNode, options));
48
+ res.push(new NotEqualNode(rightNode, leftNode, options));
49
+ });
50
+ });
51
+ return res;
52
+ }
53
+ toAllValidTexs(opts) {
54
+ const options = opts ?? this.opts;
55
+ return this.toEquivalentNodes(options).map((node) => node.toTex());
56
+ }
57
+ toMathString() {
58
+ return `${this.leftChild.toMathString()} != ${this.rightChild.toMathString()}`;
59
+ }
60
+ toTex() {
61
+ return `${this.leftChild.toTex()} \\neq ${this.rightChild.toTex()}`;
62
+ }
63
+ shuffle() {
64
+ return coinFlip() ? this : this.reverse();
65
+ }
66
+ reverse() {
67
+ return new NotEqualNode(this.rightChild, this.leftChild, this.opts);
68
+ }
69
+ evaluate() {
70
+ throw new Error("unimplemented");
71
+ }
72
+ toDetailedEvaluation() {
73
+ throw new Error("unimplemented");
74
+ }
75
+ simplify() {
76
+ throw new Error("unimplemented");
77
+ }
78
+ equals() {
79
+ throw new Error("unimplemented");
80
+ }
81
+ derivative() {
82
+ throw new Error("unimplemented");
83
+ }
84
+ }
@@ -0,0 +1,16 @@
1
+ import { AlgebraicNode, SimplifyOptions } from "../nodes/algebraicNode.js";
2
+ import { ToTexOptions } from "../nodes/node.js";
3
+ export declare abstract class NodeSimplifier {
4
+ static getDepth: <T extends AlgebraicNode>(algebraicNode: T, simplifyOpts: SimplifyOptions, toTexOptions?: ToTexOptions) => number;
5
+ static getPEMDASPriority: (algebraicNode: AlgebraicNode) => 1 | 0 | 2 | 100 | -1 | 3 | 4 | 5;
6
+ static nodesSortedByPEMDASPriorityAsc: (nodes: AlgebraicNode[]) => AlgebraicNode[];
7
+ static nodesStepByStep: <T extends AlgebraicNode>(algebraicNode: T, simplifyOpts: SimplifyOptions, simplifierOpts?: {
8
+ isMultiTopLevel: boolean;
9
+ }, toTexOpts?: ToTexOptions) => AlgebraicNode[];
10
+ static arrTexStepByStep: (node: AlgebraicNode, simplifyOpts?: SimplifyOptions, simplifierOpts?: {
11
+ isMultiTopLevel: boolean;
12
+ }, toTexOpts?: ToTexOptions) => string[];
13
+ private static getCreateNodeFromChildrenFunction;
14
+ static getChildren(algebraicNode: AlgebraicNode): AlgebraicNode[];
15
+ }
16
+ //# sourceMappingURL=nodeSimplifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeSimplifier.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodeSimplifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAmC3E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,8BAAsB,cAAc;IAClC,MAAM,CAAC,QAAQ,GAAI,CAAC,SAAS,aAAa,EACxC,eAAe,CAAC,EAChB,cAAc,eAAe,EAC7B,eAAc,YAIb,KACA,MAAM,CAsBP;IAEF,MAAM,CAAC,iBAAiB,GAAI,eAAe,aAAa,sCAmCtD;IAEF,MAAM,CAAC,8BAA8B,GAAI,OAAO,aAAa,EAAE,qBAK7D;IAEF,MAAM,CAAC,eAAe,GAAI,CAAC,SAAS,aAAa,EAC/C,eAAe,CAAC,EAChB,cAAc,eAAe,EAC7B,iBAAgB;QACd,eAAe,EAAE,OAAO,CAAC;KAG1B,EACD,YAAW,YAIV,KACA,aAAa,EAAE,CA4JhB;IAEF,MAAM,CAAC,gBAAgB,GACrB,MAAM,aAAa,EACnB,eAAc,eAAoB,EAClC,iBAAgB;QACd,eAAe,EAAE,OAAO,CAAC;KAG1B,EACD,YAAW,YAIV,cAQD;IAEF,OAAO,CAAC,MAAM,CAAC,iCAAiC,CAgF9C;IAEF,MAAM,CAAC,WAAW,CAAC,aAAa,EAAE,aAAa;CAShD"}
@@ -0,0 +1,283 @@
1
+ import { abs } from "../nodes/functions/absNode.js";
2
+ import { arccos } from "../nodes/functions/arccosNode.js";
3
+ import { CosNode } from "../nodes/functions/cosNode.js";
4
+ import { FunctionsIds, isFunctionNode, } from "../nodes/functions/functionNode.js";
5
+ import { AddNode, isAddNode } from "../nodes/operators/addNode.js";
6
+ import { BinomialCoefficientNode } from "../nodes/operators/binomialCoefficientNode.js";
7
+ import { DivideNode, isDivideNode } from "../nodes/operators/divideNode.js";
8
+ import { FractionNode } from "../nodes/operators/fractionNode.js";
9
+ import { isMultiplyNode, MultiplyNode, } from "../nodes/operators/multiplyNode.js";
10
+ import { PowerNode } from "../nodes/operators/powerNode.js";
11
+ import { isSubstractNode, SubstractNode, } from "../nodes/operators/substractNode.js";
12
+ import { sin } from "../nodes/functions/sinNode.js";
13
+ import { sqrt } from "../nodes/functions/sqrtNode.js";
14
+ import { tan } from "../nodes/functions/tanNode.js";
15
+ import { ArcsinNode } from "../nodes/functions/arcSinNode.js";
16
+ import { ArctanNode } from "../nodes/functions/arctanNode.js";
17
+ import { ExpNode } from "../nodes/functions/expNode.js";
18
+ import { LogNode } from "../nodes/functions/logNode.js";
19
+ import { Log10Node } from "../nodes/functions/log10Node.js";
20
+ import { NodeConstructor } from "../nodes/nodeConstructor.js";
21
+ import { isOperatorNode, OperatorIds, } from "../nodes/operators/operatorNode.js";
22
+ import { opposite } from "../nodes/functions/oppositeNode.js";
23
+ import { isNumberNode } from "../nodes/numbers/numberNode.js";
24
+ export class NodeSimplifier {
25
+ static getDepth = (algebraicNode, simplifyOpts, toTexOptions = {
26
+ forceTimesSign: true,
27
+ forceParenthesis: true,
28
+ forceNoSimplification: true,
29
+ }) => {
30
+ const children = this.getChildren(algebraicNode);
31
+ if (children.length === 0) {
32
+ return 0;
33
+ }
34
+ else {
35
+ const nodeSimplified = algebraicNode.simplify(simplifyOpts);
36
+ if (nodeSimplified.toTex(toTexOptions) === algebraicNode.toTex(toTexOptions)) {
37
+ return 0;
38
+ }
39
+ else {
40
+ return (1 +
41
+ Math.max(...children.map((nodeChild) => this.getDepth(nodeChild, simplifyOpts, toTexOptions))));
42
+ }
43
+ }
44
+ };
45
+ static getPEMDASPriority = (algebraicNode) => {
46
+ if (isOperatorNode(algebraicNode)) {
47
+ switch (algebraicNode.id) {
48
+ case OperatorIds.power:
49
+ case OperatorIds.square:
50
+ return 1;
51
+ case OperatorIds.multiply:
52
+ return 2;
53
+ case OperatorIds.divide:
54
+ case OperatorIds.fraction:
55
+ return 3;
56
+ case OperatorIds.add: {
57
+ //sometimes add is substract
58
+ const addNode = algebraicNode;
59
+ if (isNumberNode(addNode.rightChild) &&
60
+ addNode.rightChild.evaluate() < 0) {
61
+ return 5;
62
+ }
63
+ return 4;
64
+ }
65
+ case OperatorIds.substract:
66
+ return 5;
67
+ default:
68
+ return 100;
69
+ }
70
+ }
71
+ else if (isFunctionNode(algebraicNode)) {
72
+ switch (algebraicNode.id) {
73
+ default:
74
+ return 0;
75
+ }
76
+ }
77
+ else {
78
+ return -1;
79
+ }
80
+ };
81
+ static nodesSortedByPEMDASPriorityAsc = (nodes) => {
82
+ return nodes.toSorted((node1, node2) => this.getPEMDASPriority(node1) - this.getPEMDASPriority(node2));
83
+ };
84
+ static nodesStepByStep = (algebraicNode, simplifyOpts, simplifierOpts = {
85
+ isMultiTopLevel: false,
86
+ }, toTexOpts = {
87
+ forceTimesSign: true,
88
+ forceParenthesis: true,
89
+ forceNoSimplification: true,
90
+ }) => {
91
+ const depth = this.getDepth(algebraicNode, simplifyOpts, toTexOpts);
92
+ switch (depth) {
93
+ case 0:
94
+ return [algebraicNode];
95
+ case 1:
96
+ return [algebraicNode, algebraicNode.simplify(simplifyOpts)];
97
+ default:
98
+ return [
99
+ ...(() => {
100
+ const arrArrChild = this.getChildren(algebraicNode).map((nodeChild) => this.nodesStepByStep(nodeChild, simplifyOpts, simplifierOpts));
101
+ const maxLength = Math.max(...arrArrChild.map((nodesSByS) => nodesSByS.length));
102
+ //multi or single here
103
+ let arrChildren;
104
+ if (simplifierOpts.isMultiTopLevel) {
105
+ //multi
106
+ arrChildren = [...Array(maxLength - 1).keys()]
107
+ .map((i) => i + 1)
108
+ .map((i) => arrArrChild.map((nodesSByS) => nodesSByS[Math.min(i, nodesSByS.length - 1)]));
109
+ }
110
+ else {
111
+ //single: follow priority
112
+ const dictNodesSBySByPriority = arrArrChild.reduce((acc, nodesSByS, i) => {
113
+ const pemdasPriority = this.getPEMDASPriority(nodesSByS[0]);
114
+ if (!acc[pemdasPriority]) {
115
+ acc[pemdasPriority] = {};
116
+ }
117
+ acc[pemdasPriority][i] = nodesSByS;
118
+ return acc;
119
+ }, {});
120
+ arrChildren = [...Array(maxLength - 1).keys()]
121
+ .map((i) => i + 1)
122
+ .flatMap((i) => {
123
+ const indexes = Object.values(dictNodesSBySByPriority).reduce((acc, dict) => {
124
+ acc.push(...Object.keys(dict).map((k) => +k));
125
+ return acc;
126
+ }, []);
127
+ const arrDictIndex = indexes.reduce((acc, _, i) => {
128
+ const dict = indexes.reduce((acc, y, j) => {
129
+ acc[y] = j <= i;
130
+ return acc;
131
+ }, {});
132
+ acc.push(dict);
133
+ return acc;
134
+ }, []);
135
+ const arrArrWave = arrDictIndex.map((dictIndex) => {
136
+ return arrArrChild.map((nodesSByS, k) => {
137
+ if (dictIndex[k]) {
138
+ return nodesSByS[Math.min(i, nodesSByS.length - 1)];
139
+ }
140
+ else {
141
+ return nodesSByS[Math.min(i - 1, nodesSByS.length - 1)];
142
+ }
143
+ });
144
+ });
145
+ //keep distinct
146
+ const dictDistinct = Object.fromEntries(arrArrWave.map((arrChild) => {
147
+ const strId = arrChild
148
+ .map((node) => node.toTex(toTexOpts))
149
+ .join("&&&");
150
+ return [strId, arrChild];
151
+ }));
152
+ return Object.values(dictDistinct);
153
+ });
154
+ }
155
+ const isNeedsRewritingAddToSub = (algebraicNode, children) => {
156
+ const isAdd = () => isAddNode(algebraicNode);
157
+ const isAddXSub = () => {
158
+ return isSubstractNode(children[1]);
159
+ };
160
+ const isAddXAddYNeg = () => {
161
+ return (isAddNode(children[1]) &&
162
+ // isNumberNode(children[1].rightChild) &&
163
+ children[1].rightChild.evaluate() < 0);
164
+ };
165
+ return isAdd() && (isAddXSub() || isAddXAddYNeg());
166
+ };
167
+ const isNeedsRewritingMultToDiv = (algebraicNode, children) => {
168
+ const isMult = () => isMultiplyNode(algebraicNode);
169
+ const isMultXDiv = () => {
170
+ return isDivideNode(children[1]);
171
+ };
172
+ return isMult() && isMultXDiv();
173
+ };
174
+ return arrChildren.map((childrenRefined) => {
175
+ if (childrenRefined.length === 2) {
176
+ if (isNeedsRewritingAddToSub(algebraicNode, childrenRefined)) {
177
+ //a + (b - c) -> (a + b) - c
178
+ if (isSubstractNode(childrenRefined[1])) {
179
+ const subNode = childrenRefined[1];
180
+ return new SubstractNode(new AddNode(childrenRefined[0], subNode.leftChild), subNode.rightChild);
181
+ }
182
+ else {
183
+ const addNode = childrenRefined[1];
184
+ return new SubstractNode(new AddNode(childrenRefined[0], addNode.leftChild), abs(addNode.rightChild).simplify());
185
+ }
186
+ }
187
+ else if (isNeedsRewritingMultToDiv(algebraicNode, childrenRefined)) {
188
+ //a * (b / c) -> (a * b) / c
189
+ const divNode = childrenRefined[1];
190
+ return new DivideNode(new MultiplyNode(childrenRefined[0], divNode.leftChild), divNode.rightChild);
191
+ }
192
+ else {
193
+ return this.getCreateNodeFromChildrenFunction(algebraicNode)(childrenRefined);
194
+ }
195
+ }
196
+ else {
197
+ return this.getCreateNodeFromChildrenFunction(algebraicNode)(childrenRefined);
198
+ }
199
+ });
200
+ })(),
201
+ algebraicNode.simplify(simplifyOpts),
202
+ ];
203
+ }
204
+ };
205
+ static arrTexStepByStep = (node, simplifyOpts = {}, simplifierOpts = {
206
+ isMultiTopLevel: false,
207
+ }, toTexOpts = {
208
+ forceTimesSign: true,
209
+ forceParenthesis: true,
210
+ forceNoSimplification: true,
211
+ }) => {
212
+ return this.nodesStepByStep(node, simplifyOpts, simplifierOpts, toTexOpts).map((node) => node.toTex(toTexOpts));
213
+ };
214
+ static getCreateNodeFromChildrenFunction = (algebraicNode) => {
215
+ if (isOperatorNode(algebraicNode)) {
216
+ switch (algebraicNode.id) {
217
+ case OperatorIds.binomialCoefficient:
218
+ return (children) => new BinomialCoefficientNode(children[0], children[1], algebraicNode.opts);
219
+ case OperatorIds.divide:
220
+ return (children) => new DivideNode(children[0], children[1]);
221
+ case OperatorIds.fraction:
222
+ return (children) => new FractionNode(children[0], children[1], algebraicNode.opts);
223
+ case OperatorIds.integral:
224
+ // throw new Error("unsupported node type: integral"); //need to do intelligent shuffle here
225
+ return () => NodeConstructor.fromIdentifiers(algebraicNode.toIdentifiers());
226
+ case OperatorIds.limit:
227
+ // throw new Error("unsupported node type: limit"); //need to do intelligent shuffle here
228
+ return () => NodeConstructor.fromIdentifiers(algebraicNode.toIdentifiers());
229
+ case OperatorIds.multiply:
230
+ return (children) => new MultiplyNode(children[0], children[1], algebraicNode.opts);
231
+ case OperatorIds.power:
232
+ case OperatorIds.square: //this is so nice
233
+ return (children) => new PowerNode(children[0], children[1], algebraicNode.opts);
234
+ case OperatorIds.substract:
235
+ return (children) => new SubstractNode(children[0], children[1], algebraicNode.opts);
236
+ case OperatorIds.add:
237
+ return (children) => new AddNode(children[0], children[1], algebraicNode.opts);
238
+ }
239
+ }
240
+ else if (isFunctionNode(algebraicNode)) {
241
+ switch (algebraicNode.id) {
242
+ case FunctionsIds.arccos:
243
+ return (children) => arccos(children[0]);
244
+ case FunctionsIds.arcsin:
245
+ return (children) => new ArcsinNode(children[0]);
246
+ case FunctionsIds.arctan:
247
+ return (children) => new ArctanNode(children[0]);
248
+ case FunctionsIds.cos:
249
+ return (children) => new CosNode(children[0]);
250
+ case FunctionsIds.exp:
251
+ return (children) => new ExpNode(children[0], algebraicNode.opts);
252
+ case FunctionsIds.log:
253
+ return (children) => new LogNode(children[0], algebraicNode.opts);
254
+ case FunctionsIds.log10:
255
+ return (children) => new Log10Node(children[0], algebraicNode.opts);
256
+ case FunctionsIds.opposite:
257
+ return (children) => opposite(children[0]);
258
+ case FunctionsIds.sin:
259
+ return (children) => sin(children[0]);
260
+ case FunctionsIds.sqrt:
261
+ return (children) => sqrt(children[0]);
262
+ case FunctionsIds.tan:
263
+ return (children) => tan(children[0]);
264
+ case FunctionsIds.abs:
265
+ return (children) => abs(children[0]);
266
+ }
267
+ }
268
+ else {
269
+ return () => NodeConstructor.fromIdentifiers(algebraicNode.toIdentifiers());
270
+ }
271
+ };
272
+ static getChildren(algebraicNode) {
273
+ if (isOperatorNode(algebraicNode)) {
274
+ return [algebraicNode.leftChild, algebraicNode.rightChild];
275
+ }
276
+ else if (isFunctionNode(algebraicNode)) {
277
+ return [algebraicNode.child];
278
+ }
279
+ else {
280
+ return [];
281
+ }
282
+ }
283
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.146",
4
+ "version": "3.0.148",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [