This week’s challenge is brought to you by the guys over at repl.it !
You are to take a alegebraic equation input from the user. Here, you can either take only the coefficients of the terms as input or the entire equation and then solve it!
(YES, write a program to do your homework)
And as for the equation, it should be able to solve up to 2nd degree equations. Any higher than that is entirely up to you! A sample is given below.
User input :
(x ** 2) - 6x + 8 = 0
x = [2, 4]
NOTE : You can give the output in any readable form that you prefer. The variable in the user entered equation will always be
xunless you decide to only take the coefficients for the input, in which case, it is in your hands.
And as usual, it should all have proper prompts and human readable interactions.
For submitting your repls, post them on the repl talk share board and ensure that they contain
#WEEKLY in their name.
NOTE : You cannot have multiple weekly challenge submissions but if you want to share multiple ways of achieving the goal, you can make regular posts that don’t contain
#WEEKLYin their name, even
And that’s it for today, code away and have fun replers!
That’s the prompt! What do you guys think? Sounds like fun. As always, feel free to post your solutions down below (and of course, if you are up to it, share them at repl.it as well ) Here is some Q&A from the original post that clarifies some things:
Should it also be able to get any solutions with complex numbers? Also, should it support the methods of notating exponents as
**? Also, should it include trigonometry, exponential functions, logarithms, and rational functions or just linear and quadratic functions?
- Complex numbers are optional.
- It’s up to you but by default I am going to assume it to be
**so you would need to specify if you want me to type in some other format.
- Only linear and quadratic functions are required. Others can be added for bonus but won’t account to your actual score.
POG so by equations, you mean:
- a * (x ** 2) + bx + c = 0 - ax + c = 0