# Khan/khan-exercises

```I fixed a bug where it would accept answers with missing + signs and made it so that the regex never contains \s*\s*.

Test Plan:
Same as 66a5ed8 but also tested seed 33 with the answer (−85x)(x−3) and it correctly rejected it.

Auditors: eater, cbhl```
1 parent 1621da4 commit fa43cbd5b1a7fad7d0561b52c642df66ff2ef4fc spicyj committed Apr 4, 2013
Showing with 9 additions and 32 deletions.
1. +9 −32 exercises/factoring_polynomials_by_grouping_1.html
41 exercises/factoring_polynomials_by_grouping_1.html
 @@ -15,14 +15,15 @@ randRangeNonZero(-5, 5) E + A * F E * F - "\\(\\s*" + (A < 0 ? "[-\u2212]" : "") + abs(A) + "[xX]\\s*" + (E < 0 ? "[-\u2212]" : "\\+") + "\\s*" + abs(E) + "\\s*\\)" - "\\(\\s*" + (E < 0 ? "[-\u2212]" : "") + "\\s*" + abs(E) + (A < 0 ? "[-\u2212]" : "") + abs(A) + "[xX]\\s*" + "\\s*\\)" - "\\(\\s*[xX]\\s*" + (F < 0 ? "[-\u2212]" : "\\+") + "\\s*" + abs(F) + "\\s*\\)" - "\\(\\s*" + (F < 0 ? "[-\u2212]" : "") + "\\s*" + abs(F) + "\\s*\\+\\s*[xX]\\s*\\)" - "\\(\\s*" + (A > 0 ? "[-\u2212]" : "") + abs(A) + "[xX]\\s*" + (E > 0 ? "[-\u2212]" : "\\+") + "\\s*" + abs(E) + "\\s*\\)" - "\\(\\s*" + (E > 0 ? "[-\u2212]" : "") + "\\s*" + abs(E) + "\\s*" + (A > 0 ? "[-\u2212]" : "\\+") + abs(A) + "\\s*[xX]\\s*" + "\\s*\\)" - "\\(\\s*[-\u2212]\\s*[xX]\\s*" + (F > 0 ? "[-\u2212]" : "\\+") + "\\s*" + abs(F) + "\\s*\\)" - "\\(\\s*" + (F > 0 ? "[-\u2212]" : "") + "\\s*" + abs(F) + "\\s*[-\u2212]\\s*[xX]\\s*\\)" + + "(?:\\(\\s*" + (A < 0 ? "[-\u2212]\\s*" : "") + abs(A) + "\\s*[xX]\\s*" + (E < 0 ? "[-\u2212]" : "\\+") + "\\s*" + abs(E) + "\\s*\\)|" + + "\\(\\s*" + (E < 0 ? "[-\u2212]\\s*" : "") + abs(E) + "\\s*" + (A < 0 ? "[-\u2212]" : "\\+") + "\\s*" + abs(A) + "\\s*[xX]\\s*\\))" + "(?:\\(\\s*[xX]\\s*" + (F < 0 ? "[-\u2212]" : "\\+") + "\\s*" + abs(F) + "\\s*\\)|" + + "\\(\\s*" + (F < 0 ? "[-\u2212]\\s*" : "") + abs(F) + "\\s*\\+\\s*[xX]\\s*\\))" + "(?:\\(\\s*" + (-A < 0 ? "[-\u2212]\\s*" : "") + abs(A) + "\\s*[xX]\\s*" + (-E < 0 ? "[-\u2212]\\s*" : "\\+") + abs(E) + "\\s*\\)|" + + "\\(\\s*" + (-E < 0 ? "[-\u2212]\\s*" : "") + abs(E) + "\\s*" + (-A < 0 ? "[-\u2212]\\s*" : "\\+") + abs(A) + "\\s*[xX]\\s*\\))" + "(?:\\(\\s*[-\u2212]\\s*[xX]\\s*" + (-F < 0 ? "[-\u2212]" : "\\+") + "\\s*" + abs(F) + "\\s*\\)|" + + "\\(\\s*" + (-F < 0 ? "[-\u2212]\\s*" : "") + abs(F) + "\\s*[-\u2212]\\s*[xX]\\s*\\))"

Factor the following expression:

@@ -34,37 +35,13 @@
^\s*AX_PLUS_E\s*X_PLUS_F\s*\$
-
^\s*AX_PLUS_E\s*F_PLUS_X\s*\$
-
^\s*E_PLUS_AX\s*X_PLUS_F\s*\$
-
^\s*E_PLUS_AX\s*F_PLUS_X\s*\$
^\s*X_PLUS_F\s*AX_PLUS_E\s*\$
-
^\s*F_PLUS_X\s*AX_PLUS_E\s*\$
-
^\s*X_PLUS_F\s*E_PLUS_AX\s*\$
-
^\s*F_PLUS_X\s*E_PLUS_AX\s*\$
^\s*NEG_AX_MINUS_E\s*NEG_X_MINUS_F\s*\$
-
^\s*NEG_AX_MINUS_E\s*NEG_F_MINUS_X\s*\$
-
^\s*NEG_E_MINUS_AX\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