polynomials with bounded coefficients
I have a list L, and would like to construct all polynomials of degree d, with coefficients from the list. An example is the following :
SET=[];
K.<a>=FiniteField(17);
F.<x> = PolynomialRing(K,'x');
for f in F.monics( of_degree=8):
S=f.coefficients(sparse=False);
if S==([K(1),K(16)]):
SET=SET+[f];
print SET;
The above command is too time consuming. Is there a simpler way, when we can get the output in less time.