Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Handle case in combining_like_terms_2 where constant terms simplify to 0

Summary:
fix #26874; fix #29882; fix #29943; fix #29949; fix #29964; fix #29969;
fix #30088; fix #30091; fix #30108; fix #30118; fix #30138; fix #30177;
fix #30205; fix #30257; fix #30258; fix #30276; fix #30279; fix #30280

Previously, the last hint would show something like "-24a + 0" and the regex
answer would expect you to type "-24a0". This fixes the final hint to show just
"-24a" and the answer regex expects "-24a"

Test Plan:
Tested these problematic seeds outside devappserver (before and after the fix):
http://localhost:8000/exercises/combining_like_terms_2.html?debug&seed=112&problem=c_fd_fbx
http://localhost:8000/exercises/combining_like_terms_2.html?debug&seed=177&problem=c_fd_fbx
http://localhost:8000/exercises/combining_like_terms_2.html?debug&seed=161&problem=c_fd_fbx

Reviewers: stephanie

Reviewed By: stephanie

Differential Revision: http://phabricator.khanacademy.org/D742
  • Loading branch information...
commit 8183d56db10b96c191e1460658c45200feaed166 1 parent 63baa80
@beneater beneater authored
Showing with 13 additions and 9 deletions.
  1. +13 −9 exercises/combining_like_terms_2.html
View
22 exercises/combining_like_terms_2.html
@@ -43,11 +43,11 @@
+ (E * A + F * B === 1 ? "|" : "" ) + (E * A + F * B === -1 ?
"|[-\\u2212]" : "") + ")\\s*" + X
</var>
- <var id="TERM_C">(C &lt; 0 ? "[-\\u2212]\\s*" : "") + abs(C)</var>
- <var id="TERM_C_D">((C + D) &lt; 0 ? "[-\\u2212]\\s*" : "") + abs(C + D)</var>
- <var id="TERM_FD">((F * D) &lt; 0 ? "[-\\u2212]\\s*" : "") + abs(F * D)</var>
- <var id="TERM_C_FD">((C + F * D) &lt; 0 ? "[-\\u2212]\\s*" : "") + abs(C + F * D)</var>
- <var id="TERM_EC_FD">((E * C + F * D) &lt; 0 ? "[-\\u2212]\\s*" : "") + abs(E * C + F * D)</var>
+ <var id="TERM_C">C === 0 ? "" : ((C &lt; 0 ? "[-\\u2212]\\s*" : "") + abs(C))</var>
+ <var id="TERM_C_D">(C + D) === 0 ? "" : ((C + D) &lt; 0 ? "[-\\u2212]\\s*" : "") + abs(C + D)</var>
+ <var id="TERM_FD">(F * D) === 0 ? "" : ((F * D) &lt; 0 ? "[-\\u2212]\\s*" : "") + abs(F * D)</var>
+ <var id="TERM_C_FD">(C + F * D) === 0 ? "" : ((C + F * D) &lt; 0 ? "[-\\u2212]\\s*" : "") + abs(C + F * D)</var>
+ <var id="TERM_EC_FD">(E * C + F * D) === 0 ? "" : ((E * C + F * D) &lt; 0 ? "[-\\u2212]\\s*" : "") + abs(E * C + F * D)</var>
</div>
<p class="question">
Simplify the following expression:
@@ -101,7 +101,8 @@
<code>\qquad\pink{<var>expr(["*", A + (F * B), X])</var>} + <var>F * D</var></code>
</p>
</div>
- <p>The simplified expression is <code><var>expr(["+", ["*", A + (F * B), X], F * D])</var></code>
+ <p data-if="F * D === 0">The simplified expression is <code><var>expr(["*", A + (F * B), X])</var></code>
+ <p data-else>The simplified expression is <code><var>expr(["+", ["*", A + (F * B), X], F * D])</var></code>
</div>
</div>
@@ -157,7 +158,8 @@
\blue{<var>C + F * D</var>}</code>
</p>
</div>
- <p>The simplified expression is <code><var>expr(["+", ["*", F * B, X], C + F * D])</var></code>
+ <p data-if="C + F * D === 0">The simplified expression is <code><var>expr(["*", F * B, X])</var></code>
+ <p data-else>The simplified expression is <code><var>expr(["+", ["*", F * B, X], C + F * D])</var></code>
</div>
</div>
@@ -243,7 +245,8 @@
\blue{<var>E * C + F * D</var>}</code>
</p>
</div>
- <p>The simplified expression is <code><var>expr(["+", ["*", E * A + F * B, X], E * C + F * D])</var></code>
+ <p data-if="E * C + F * D === 0">The simplified expression is <code><var>expr(["*", E * A + F * B, X])</var></code>
+ <p data-else>The simplified expression is <code><var>expr(["+", ["*", E * A + F * B, X], E * C + F * D])</var></code>
</div>
</div>
@@ -323,7 +326,8 @@
\blue{<var>E * C + F * D</var>}</code>
</p>
</div>
- <p>The simplified expression is <code><var>expr(["+", ["*", E * A + F * B, X], E * C + F * D])</var></code>
+ <p data-if="E * C + F * D">The simplified expression is <code><var>expr(["*", E * A + F * B, X])</var></code>
+ <p data-else>The simplified expression is <code><var>expr(["+", ["*", E * A + F * B, X], E * C + F * D])</var></code>
</div>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.