Kumar-laxmi / Algorithms

A Repository for algorithms in C, C++, Python and Java
Apache License 2.0
310 stars 372 forks source link

Expression Evaluator #1555

Closed Anirudh3167 closed 2 months ago

Anirudh3167 commented 1 year ago

Is your feature request related to a problem? Please describe. The features is new in this codebase but a part of it is used in #1554

Describe the solution you'd like This is like a command line. You can either type a mathematical expression or an equation. The algorithm will solve it for you just like the calculator

Describe alternatives you've considered Although the calculator is used for these purposes but it cannot be used in programming. A specific algorithm is needed.

In case of Python you can consider using eval() for this. In case of Java you can call javascript engine and can use the power DOM for calculations.

Additional context Working :-

  1. The Expression Evaluator will first remove the spaces and replace x variable in case of equation
  2. Then it will solve by brackets starting from the inner most brackets.
  3. BODMAS is followed.
  4. The result is then calculated.

Limitations :-

  1. Single variable
  2. The expression / equation should be in format of
  3. cases like 5*-2 will not be evaluated since it is not following the 2.

Kindly assign this issue to me

harshitaaa8 commented 1 year ago

I can also work on this issue in python and c.

github-actions[bot] commented 2 months ago

Stale issue message