math-exercises 2.0.10 → 2.0.12
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.
- package/lib/exercises/exercise.d.ts +1 -1
- package/lib/exercises/exercise.d.ts.map +1 -1
- package/lib/exercises/functions/affines/leadingCoefficient.d.ts.map +1 -1
- package/lib/exercises/functions/affines/leadingCoefficient.js +5 -1
- package/lib/exercises/functions/logarithm/logPowerEquation.d.ts.map +1 -1
- package/lib/exercises/functions/logarithm/logPowerEquation.js +2 -2
- package/lib/exercises/geometry/vectors/index.d.ts +1 -0
- package/lib/exercises/geometry/vectors/index.d.ts.map +1 -1
- package/lib/exercises/geometry/vectors/index.js +1 -0
- package/lib/exercises/geometry/vectors/scalarProductViaCoords.js +1 -1
- package/lib/exercises/geometry/vectors/scalarProductViaCos.d.ts +9 -0
- package/lib/exercises/geometry/vectors/scalarProductViaCos.d.ts.map +1 -0
- package/lib/exercises/geometry/vectors/scalarProductViaCos.js +66 -0
- package/lib/exercises/limits/index.d.ts +1 -0
- package/lib/exercises/limits/index.d.ts.map +1 -1
- package/lib/exercises/limits/index.js +1 -0
- package/lib/exercises/limits/limitReading.d.ts +10 -0
- package/lib/exercises/limits/limitReading.d.ts.map +1 -0
- package/lib/exercises/limits/limitReading.js +111 -0
- package/lib/exercises/squareRoots/index.d.ts +3 -0
- package/lib/exercises/squareRoots/index.d.ts.map +1 -1
- package/lib/exercises/squareRoots/index.js +3 -0
- package/lib/exercises/squareRoots/squareRootIdentities.d.ts +11 -0
- package/lib/exercises/squareRoots/squareRootIdentities.d.ts.map +1 -0
- package/lib/exercises/squareRoots/squareRootIdentities.js +124 -0
- package/lib/exercises/squareRoots/squareRootsDistributivity.d.ts +10 -0
- package/lib/exercises/squareRoots/squareRootsDistributivity.d.ts.map +1 -0
- package/lib/exercises/squareRoots/squareRootsDistributivity.js +67 -0
- package/lib/exercises/squareRoots/squareRootsSum.d.ts +13 -0
- package/lib/exercises/squareRoots/squareRootsSum.d.ts.map +1 -0
- package/lib/exercises/squareRoots/squareRootsSum.js +79 -0
- package/lib/index.d.ts +28 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/server.js +11 -1
- package/lib/tree/nodes/algebraicNode.d.ts +4 -1
- package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/oppositeNode.d.ts +2 -2
- package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/oppositeNode.js +2 -2
- package/lib/tree/nodes/functions/sqrtNode.d.ts +2 -2
- package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sqrtNode.js +3 -3
- package/lib/tree/nodes/node.d.ts +4 -1
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/numberNode.d.ts +3 -0
- package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/numberNode.js +8 -1
- package/lib/tree/nodes/operators/addNode.d.ts +2 -2
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +5 -3
- package/lib/tree/nodes/operators/fractionNode.d.ts +2 -2
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +4 -4
- package/lib/tree/nodes/operators/limitNode.d.ts +29 -0
- package/lib/tree/nodes/operators/limitNode.d.ts.map +1 -0
- package/lib/tree/nodes/operators/limitNode.js +56 -0
- package/lib/tree/nodes/operators/multiplyNode.d.ts +2 -2
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +5 -5
- package/lib/tree/nodes/operators/operatorNode.d.ts +2 -1
- package/lib/tree/nodes/operators/operatorNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/operatorNode.js +1 -0
- package/lib/tree/nodes/operators/powerNode.d.ts +2 -2
- package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/powerNode.js +51 -2
- package/lib/tree/nodes/operators/substractNode.d.ts +2 -2
- package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/substractNode.js +2 -2
- package/lib/utils/randomLetter.d.ts +1 -1
- package/lib/utils/randomLetter.d.ts.map +1 -1
- package/lib/utils/randomLetter.js +6 -4
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powerNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/powerNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"powerNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/powerNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOlE,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,SAAS,CAEnD;AAED,qBAAa,SAAU,YAAW,YAAY;IAC5C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB,YAAY,IAAI,MAAM;IAItB,iBAAiB;IAqBjB,cAAc,IAAI,MAAM,EAAE;IAI1B,KAAK,IAAI,MAAM;IAuBf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IA+FrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAO/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAOrC;AAED,qBAAa,UAAW,SAAQ,SAAS;gBAC3B,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;CAGrD"}
|
|
@@ -77,6 +77,7 @@ class PowerNode {
|
|
|
77
77
|
// simplify(): AlgebraicNode {
|
|
78
78
|
// const leftSimplified = this.leftChild.simplify();
|
|
79
79
|
// const rightSimplified = this.rightChild.simplify();
|
|
80
|
+
// const copy = new PowerNode(leftSimplified, rightSimplified, this.opts);
|
|
80
81
|
// if (isNumberNode(rightSimplified)) {
|
|
81
82
|
// const value = rightSimplified.value;
|
|
82
83
|
// if (value === 0) return new NumberNode(1);
|
|
@@ -87,6 +88,36 @@ class PowerNode {
|
|
|
87
88
|
// if (value === 0) return leftSimplified;
|
|
88
89
|
// if (value === 1) return leftSimplified;
|
|
89
90
|
// }
|
|
91
|
+
// let externals: AlgebraicNode[] = [];
|
|
92
|
+
// //TODO Fractions
|
|
93
|
+
// const recursive = (node: AlgebraicNode) => {
|
|
94
|
+
// if (isMultiplyNode(node)) {
|
|
95
|
+
// recursive(node.leftChild);
|
|
96
|
+
// recursive(node.rightChild);
|
|
97
|
+
// } else {
|
|
98
|
+
// externals.push(node);
|
|
99
|
+
// }
|
|
100
|
+
// };
|
|
101
|
+
// recursive(copy.leftChild)
|
|
102
|
+
// const simplifyIteration = () => {
|
|
103
|
+
// for (let i = 0; i < externals.length - 1; i++) {
|
|
104
|
+
// const left = externals[i];
|
|
105
|
+
// for (let j = i + 1; j < externals.length; j++) {
|
|
106
|
+
// const right = externals[j];
|
|
107
|
+
// const simplified = simplifyExternalNodes(left, right);
|
|
108
|
+
// if (simplified) {
|
|
109
|
+
// externals[i] = simplified;
|
|
110
|
+
// externals.splice(j, 1);
|
|
111
|
+
// if (isNumberNode(simplified) && simplified.value === 1) {
|
|
112
|
+
// externals.splice(i, 1);
|
|
113
|
+
// }
|
|
114
|
+
// simplifyIteration();
|
|
115
|
+
// return;
|
|
116
|
+
// }
|
|
117
|
+
// }
|
|
118
|
+
// }
|
|
119
|
+
// };
|
|
120
|
+
// simplifyIteration();
|
|
90
121
|
// if (isNumberNode(rightSimplified) && isNumberNode(leftSimplified)) {
|
|
91
122
|
// const value = this.evaluate({});
|
|
92
123
|
// // à partir de ^21 et de ^-7, javascript returns des écritures scientifiques
|
|
@@ -107,11 +138,29 @@ class PowerNode {
|
|
|
107
138
|
// ).simplify();
|
|
108
139
|
// }
|
|
109
140
|
// if (isSqrtNode(leftSimplified) && isNumberNode(rightSimplified)) {
|
|
141
|
+
// const powerValue = rightSimplified.value;
|
|
142
|
+
// const powerIsEven = powerValue % 2 === 0;
|
|
143
|
+
// if (powerIsEven) {
|
|
144
|
+
// return new PowerNode(
|
|
145
|
+
// leftSimplified.child,
|
|
146
|
+
// new NumberNode(powerValue / 2),
|
|
147
|
+
// ).simplify();
|
|
148
|
+
// } else {
|
|
149
|
+
// const parityPower = Math.floor(powerValue / 2);
|
|
150
|
+
// return new MultiplyNode(
|
|
151
|
+
// new PowerNode(leftSimplified.child, new NumberNode(parityPower)),
|
|
152
|
+
// leftSimplified,
|
|
153
|
+
// ).simplify();
|
|
154
|
+
// }
|
|
110
155
|
// }
|
|
111
|
-
//
|
|
156
|
+
// return this;
|
|
112
157
|
// // puissances négatives ?
|
|
113
158
|
// }
|
|
114
|
-
simplify() {
|
|
159
|
+
simplify(opts) {
|
|
160
|
+
//! temporaire
|
|
161
|
+
if ((0, numberNode_1.isNumberNode)(this.rightChild) && this.rightChild.value === 2) {
|
|
162
|
+
return new multiplyNode_1.MultiplyNode(this.leftChild, this.leftChild).simplify(opts);
|
|
163
|
+
}
|
|
115
164
|
return this;
|
|
116
165
|
}
|
|
117
166
|
equals(node) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node, NodeType } from "../node";
|
|
2
2
|
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
|
-
import { AlgebraicNode } from "../algebraicNode";
|
|
3
|
+
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode";
|
|
4
4
|
export declare function isSubstractNode(a: Node): a is SubstractNode;
|
|
5
5
|
export declare class SubstractNode implements OperatorNode {
|
|
6
6
|
id: OperatorIds;
|
|
@@ -14,7 +14,7 @@ export declare class SubstractNode implements OperatorNode {
|
|
|
14
14
|
toAllValidTexs(): string[];
|
|
15
15
|
toTex(): string;
|
|
16
16
|
evaluate(vars: Record<string, number>): number;
|
|
17
|
-
simplify():
|
|
17
|
+
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
18
18
|
equals(node: AlgebraicNode): boolean;
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=substractNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"substractNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/substractNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"substractNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/substractNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,aAAa,CAE3D;AACD,qBAAa,aAAc,YAAW,YAAY;IAChD,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBACP,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa;IAQ/D,YAAY,IAAI,MAAM;IAItB,iBAAiB,IAAI,aAAa,EAAE;IAapC,cAAc,IAAI,MAAM,EAAE;IAG1B,KAAK,IAAI,MAAM;IAef,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;IAM/B,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAOrC"}
|
|
@@ -52,8 +52,8 @@ class SubstractNode {
|
|
|
52
52
|
// toMathjs() {
|
|
53
53
|
// return subtract(this.leftChild.toMathjs(), this.rightChild.toMathjs());
|
|
54
54
|
// }
|
|
55
|
-
simplify() {
|
|
56
|
-
return this;
|
|
55
|
+
simplify(opts) {
|
|
56
|
+
return new addNode_1.AddNode(this.leftChild, new oppositeNode_1.OppositeNode(this.rightChild)).simplify(opts);
|
|
57
57
|
}
|
|
58
58
|
equals(node) {
|
|
59
59
|
return (isSubstractNode(node) &&
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const randomLetter: (isMaj?: boolean) => string;
|
|
1
|
+
export declare const randomLetter: (isMaj?: boolean, excludes?: string[]) => string;
|
|
2
2
|
//# sourceMappingURL=randomLetter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randomLetter.d.ts","sourceRoot":"","sources":["../../src/utils/randomLetter.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"randomLetter.d.ts","sourceRoot":"","sources":["../../src/utils/randomLetter.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,WAChB,OAAO,aACJ,MAAM,EAAE,WASnB,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.randomLetter = void 0;
|
|
4
|
-
const randomLetter = (isMaj = false) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const randomLetter = (isMaj = false, excludes = []) => {
|
|
5
|
+
let letter = "";
|
|
6
|
+
do {
|
|
7
|
+
letter = String.fromCharCode((isMaj ? 65 : 97) + Math.floor(Math.random() * 26));
|
|
8
|
+
} while (excludes.includes(letter));
|
|
9
|
+
return letter;
|
|
8
10
|
};
|
|
9
11
|
exports.randomLetter = randomLetter;
|