math-exercises 2.1.26-beta.11 → 2.1.26-beta.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"drawAVectorInGGB.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/drawAVectorInGGB.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAIT,MAAM,0BAA0B,CAAC;AAMlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsCF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAalD,CAAC"}
1
+ {"version":3,"file":"drawAVectorInGGB.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/drawAVectorInGGB.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAIT,MAAM,0BAA0B,CAAC;AAMlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAuDF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAalD,CAAC"}
@@ -30,12 +30,30 @@ const isGGBAnswerValid = (ans, { ggbAnswer, x, y }) => {
30
30
  const vector = ans.find((s) => !!s.match(/[a-z]=/)?.length);
31
31
  if (!vector)
32
32
  return false;
33
- const coords = vector
34
- .substring(vector.indexOf("=") + 1)
33
+ const points = vector
34
+ .substring(vector.indexOf("["))
35
+ .replaceAll("[", "")
36
+ .replaceAll("]", "")
37
+ .replaceAll(" ", "")
38
+ .split(",");
39
+ const origin = ans.find((s) => s[0] === points[0]);
40
+ const end = ans.find((s) => s[0] === points[1]);
41
+ if (!origin || !end)
42
+ return false;
43
+ const originCoords = origin
44
+ .split("=")[1]
45
+ .replaceAll("(", "")
46
+ .replaceAll(")", "")
47
+ .split(",");
48
+ const endCoords = end
49
+ .split("=")[1]
35
50
  .replaceAll("(", "")
36
51
  .replaceAll(")", "")
37
52
  .split(",");
38
- console.log(coords);
53
+ const coords = [
54
+ Number(endCoords[0]) - Number(originCoords[0]),
55
+ Number(endCoords[1]) - Number(originCoords[1]),
56
+ ];
39
57
  return Number(coords[0]) === x && Number(coords[1]) === y;
40
58
  };
41
59
  exports.drawAVectorInGGB = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "2.1.26-beta.11",
3
+ "version": "2.1.26-beta.13",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [