Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

No longer accept answers with a negative denominator

  • Loading branch information...
commit 77426f4de6a4d94958cd66255680c16db5812198 1 parent b99392d
@petercollingridge petercollingridge authored
Showing with 12 additions and 10 deletions.
  1. +12 −10 exercises/simplifying_rational_expressions_2.html
View
22 exercises/simplifying_rational_expressions_2.html
@@ -98,10 +98,16 @@
<var id="DENOMINATORSOL">expr(["+", ["*", COEFFICIENT2, X], CONSTANT2])</var>
<var id="NEGNUMERATORSOL">expr(["+", ["*", -COEFFICIENT1, X], -CONSTANT1])</var>
<var id="NEGDENOMINATORSOL">expr(["+", ["*", -COEFFICIENT2, X], -CONSTANT2])</var>
- <var id="POSITIVENUMERATOR">getExpressionRegex(COEFFICIENT1, X, CONSTANT1)</var>
- <var id="POSITIVEDENOMINATOR">getExpressionRegex(COEFFICIENT2, X, CONSTANT2)</var>
- <var id="NEGATIVENUMERATOR">getExpressionRegex(-COEFFICIENT1, X, -CONSTANT1)</var>
- <var id="NEGATIVEDENOMINATOR">getExpressionRegex(-COEFFICIENT2, X, -CONSTANT2)</var>
+ <var id="REGEX">(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)];
+ }
+ })()
+ </var>
</div>
<p class="question">Simplify the following expression:</p>
@@ -110,12 +116,8 @@
<div class="solution" data-type="set">
<div class="set-sol" data-type="multiple">
- <span class="sol" data-type="regex"><var>POSITIVENUMERATOR</var></span>
- <span class="sol" data-type="regex"><var>POSITIVEDENOMINATOR</var></span>
- </div>
- <div class="set-sol" data-type="multiple">
- <span class="sol" data-type="regex"><var>NEGATIVENUMERATOR</var></span>
- <span class="sol" data-type="regex"><var>NEGATIVEDENOMINATOR</var></span>
+ <span class="sol" data-type="regex"><var>REGEX[0]</var></span>
+ <span class="sol" data-type="regex"><var>REGEX[1]</var></span>
</div>
<div class="input-format">
<div class="entry" data-type="multiple">
Please sign in to comment.
Something went wrong with that request. Please try again.