The challenge is to write the shortest function/program to find a polynomial given the roots. The function or program should take valid input; that is, a list of integers representing the roots of the polynomial, and return valid output.
Output should return a sequence of numbers representing the polynomial. For example:
2, 3
represents 2x^1 - 3x^0 = 0
1, 6, 1, 8, 0, 3, 3
represents 1x^6 + 6x^5 + 1x^4 + 8x^3 + 0x^2 + 3x^1 + 3x^0 = 0
-1 0 5, -3
represents -1x^3 + 0x^2 + 5x^1 + -3x^0 = 0
I hope you get the idea.
Example Usage
For an input of 1, 2
, the output should be 1, -3, 2
, which represents the equation 1x^2 + -3x^1 + 2x^0 = 0
, or x^2 - 3x + 2 = 0
.
For an input of 1, -1, 0
, the output should be 1, 0, -1, 0
.
For the input, duplicate values should be removed and order does not matter. For example, the result with input 3, 3, 6
should be the same as the result with input 6, 3
.
Float arguments are optional.
As this is code golf, the shortest entry in characters wins. Good luck!
bytes
and notcharacters
. I would advise the former. The latter encourages weird base256/unicode compression of the source, which IMO don't really add anything to the contest, and merely serve to obfuscate the code, making less accessible answers, thus decreasing the overall quality of the site. meta.codegolf.stackexchange.com/questions/2364/… \$\endgroup\$[1,2,3]
rather than"1, 2, 3"
? \$\endgroup\$