<s>[INST] How to solve this function $f(x)$ for degree $3$ or $4$ 
If $f(x)=0$ is a polynomial whose coefficients are either $1$ or $-1$ and whose roots are all real, then the degree of $f(x)$ can be equal to$:$


$A$. $1$


$B$. $2$


$C$. $3$


$D$. $4$

My work$:$
For linear only four polynomials are possible which are $x+1$ and $-x+1$ and $x-1$ and $-x-1$. All of which have real roots. So the answer is $A$.
For quadratic we have $8$ polynomials which are $x^2+x+1$ and $x^2+x-1$ and $x^2-x+1$ and $x^2-x-1$ and $-x^2+x+1$ and $-x^2-x+1$ and $-x^2+x-1$ and $-x^2-x-1$ Here four of the polynomials have real roots which are $x^2+x-1$ and $-x^2-x+1$ and $-x^2+x+1$ and $x^2-x-1$. So we can say that $f(x)$ can be of degree two. So $B$ is also the answer.
For cubic and quartic I don't know how to proceed. Any hints or solutions are appreciated.
 [/INST] Let's analyze the cubic case.
Note that the general cubic equation
$$x^3+bx^2+cx+d$$ may be reduced to the so-called depressed cubic with the substitution $x = y-b/3$.  After the algebra, we get the equivalent equation
$$y^3+py+q = y^3+(c-\frac{b^2}{3})y+(\frac{2}{27}b^3-\frac{bc}{3}+d) = 0.$$
The discriminant $\Delta$ of the cubic is given by $p^3/27+q^2/4$.  This gives us
$$\Delta = \frac{b^3 d}{27} - \frac{b^2 c^2}{108} - \frac{b c d}{6} + \frac{c^3}{27} + \frac{d^2}{4}.$$
If $\Delta \leq 0$, the cubic has all three roots being real.
Notice that from the above equation, the smallest $\Delta$ can be is $0$ which occurs if $b^3d = -1,bcd = 1,c^3 = -1$.  This requires $c = -1$ and $b,d$ to have opposite signs.  This indeed is possible.
For example, $x^3-x^2-x+1 = 0$, has roots $\pm 1$ with $1$ being a double root.
</s>