Share your repls and programming experiences

← Back to all posts
AmazingMech2418 (692)

This is my submission for Weekly Challenge #8. This supports the following:

  • Linear and quadratic equations, given that the right of the equal sign is 0.
  • Combining like terms on the left side of the equation, although there is no support for subtracting polynomials (x^2 + 2 - (2x^2 + 3) will not work), multiplying or dividing variables, or exponentiation of polynomials or algebraic terms.
  • Up to two solutions, given that they are real. Will return NaN for an imaginary solution.
  • Usage of ** or ^ for exponentiation

If you have any questions about the capabilities of this solution, please let me know.

Unlike previous submissions, this does not include comments in the code to explain how it works due to the size of the program. However, it uses a lexer and parser to combine like terms and then determines the coefficients of the resulting terms to be used in solving the equation. This could easily have support added for stuff on both sides of the equal sign, but it does not currently due to time restraints for the weekly challenges.