8
0
Challenge
Given the roots of a polynomial separated by spaces as input, output the expanded form of the polynomial.
For example, the input
1 2
represents this equation:
(x-1)(x-2)
And should output:
x^2-3x+2
The exact format of output is not important, it can be:
1x^2+-3x^1+2x^0
or:
0 0 0
1x^3+0x^2+0x^1+0
or:
3 14 15 92
1x^4+-124x^3+3241x^2+-27954x^1+57960
Scoring/Rules
evaland likes are disallowed.- You may use any version of Python or any other language.
What about built-ins like
numpy.poly? – Dennis – 2016-03-27T05:41:43.343@Dennis numpy is not built-in i think! – aliqandil – 2016-03-27T06:40:05.243
Python + NumPy answers are generally accepted, but that's beside the point. Can I use a function that turns roots into polynomial coefficients? I'm asking since you banned eval, and that's considerably more powerful than eval. – Dennis – 2016-03-27T06:42:57.037
@Dennis That pretty much the whole think! But go ahead! Since the same function is built-in in most languages. – aliqandil – 2016-03-27T09:28:14.820
can we assume the roots are integers? can we assume they are nonnegative integers? – proud haskeller – 2016-03-27T21:10:11.807