TITLE: BMO2 1997 - Combinatorics
QUESTION [18 upvotes]: Find the number of polynomials of degree 5 with distinct coefficients from the set {1, 2, 3, 4, 5, 6, 7, 8} that are divisible by $x^2-x+1$. 
I tried multiplying $x^2-x+1$ by $ax^3+bx^2+cx+d$ to get $ax^5+(b-a)x^4+(a-b+c)x^3+(b-c+d)x^2+(c-d)x+d$, but I am struggling to count from here.

REPLY [5 votes]: This is not technically a mathematical answer but I can't put more than one line of code in a comment.
I wanted to show a different way to verify the solution on a computer "all the way" up to the statement of the problem, instead of only the counting part like in @aras's answer. This uses Sagemath:
from itertools import permutations

deg = 5
max_coeff = 8

# declare polynomial ring
R.<x> = PolynomialRing(QQ, 'x')

# generate valid combinations of coefficients 
# and create the polynomials that have them as coefficients 
polys = (R(perm) for perm in permutations(range(1,max_coeff+1), deg+1))

# count valid polynomials
print sum(1 for p in polys if (x^2-x+1).divides(p))