# Khan/khan-exercises

No longer accept answers with a negative denominator

1 parent b99392d commit 77426f4de6a4d94958cd66255680c16db5812198 petercollingridge committed Mar 19, 2013
Showing with 12 additions and 10 deletions.
1. +12 −10 exercises/simplifying_rational_expressions_2.html
22 exercises/simplifying_rational_expressions_2.html
 @@ -98,10 +98,16 @@ expr(["+", ["*", COEFFICIENT2, X], CONSTANT2]) expr(["+", ["*", -COEFFICIENT1, X], -CONSTANT1]) expr(["+", ["*", -COEFFICIENT2, X], -CONSTANT2]) - getExpressionRegex(COEFFICIENT1, X, CONSTANT1) - getExpressionRegex(COEFFICIENT2, X, CONSTANT2) - getExpressionRegex(-COEFFICIENT1, X, -CONSTANT1) - getExpressionRegex(-COEFFICIENT2, X, -CONSTANT2) + (function() { + if (COEFFICIENT2 < 0 || (COEFFICIENT2 === 0 && CONSTANT1 < 0)) { + return [getExpressionRegex(-COEFFICIENT1, X, -CONSTANT1), + getExpressionRegex(-COEFFICIENT2, X, -CONSTANT2)]; + } else { + return [getExpressionRegex(COEFFICIENT1, X, CONSTANT1), + getExpressionRegex(COEFFICIENT2, X, CONSTANT2)]; + } + })() +

Simplify the following expression:

@@ -110,12 +116,8 @@
- POSITIVENUMERATOR - POSITIVEDENOMINATOR -
-
- NEGATIVENUMERATOR - NEGATIVEDENOMINATOR + REGEX[0] + REGEX[1]