0
\$\begingroup\$

I'm new to code-golf, but I was trying to solve this problem myself, and thought there must be a much "better"/shorter way of doing it.

Given a sequence (list) of numbers \$a_0, a_1,\cdots,a_n\$, your task is to write a function that returns, as a string, the polynomial with those coefficients, i.e: \$a_0+a_1x+a_2x^2+\cdots+a_nx^n\$ presented how polynomials are conventionally written, best illustrated through examples:

[1,2,3] returns 1 + 2x + 3x^2

[-1,0,1] returns -1 + x^2

[1,-2,3,-4] returns 1 - 2x + 3x^2 - 4x^3

[0,1,0,-0.5] returns x - 0.5x^3

Shortest wins, I guess!

\$\endgroup\$