Welcome to the second Coding Challenge.
Here I will post a coding challenge every few days that you can solve. There will be easy ones and hard ones, pretty mixed.
How does it work?
Try to solve the challenge in whatever language you find fitting
You can use a new language you always wanted to learn or show off your golfing skills
Post a comment with a link to your code (use https://repl.it or similar sites that allow execution of your code) and some info on how the code works or what is remarkable
Optional: Create a post with the tag #coding-solution
In that post walk other users through the process of solving your challenge. That way they can learn and try it out on the next one
Optional: Read and review other peoples code, try to find bugs, give feedback and learn
Why even bother?
Training is everything, the more you train your mind to think in code, the better you are prepared
You may learn a few new tricks from reading other solutions
I will send tips for really good solutions (and use the liquid rewards of this post for it too)
You may get recruited if someone likes your code (f.e. I am looking for talents)
Challenge #2 – Polynomial
This challenge will be an interesting one, easy to do but hard to get right.
Wikipedia context: https://en.wikipedia.org/wiki/Polynomial
Implement a Polynomial class taking an a string formula that abides to these specifications:
parse the polynomial given as a string, f.e. +1x^0 -5x^1 +3x^2
implement a few methods, add, substract, multiply, divide
implement the standart to-string method of you language to give back a polynomial in above format
Remarks:
The format is pretty easy to parse. If you want a challenge, try accepting more loose polynomials like 1+2x or 3x^{12}-6 x^2.
Try adding more methods, derive and integrate will be fun.
Bonus points for:
handling edge cases
good coding practices and modularity
useful and meaningful tests
beautiful (readable, self-documenting) code
Please keep the #coding-challenge tag clean of solutions.