6. (2003 Bulgarian Mathematical Competition) The sequence $\left\{y_{n}\right\}$ is defined as follows:
$$
y_{1}=y_{2}=1, y_{n+2}=(4 k-5) y_{n+1}-y_{n}+4-2 k, n=1,2, \cdots
$$

Find all integers $k$ such that every term in the sequence $\left\{y_{n}\right\}$ is a perfect square.
6. Starting from special cases, let $k$ be an integer that satisfies the conditions. $y_{3}=2 k-2, y_{4}=8 k^{2}-20 k+13$.

Let $2 k-2=(2 a)^{2}$, then $k=2 a^{2}+1(k \geqslant 1)$,
If $a=0$, then $k=1$; if $a>0$, then $y_{4}=32 a^{4}-8 a^{2}+1=\left(4 a^{2}-1\right)^{2}+\left(4 a^{2}\right)^{2}$, let $\left(4 a^{2}-1\right)^{2}+\left(4 a^{2}\right)^{2}=b^{2}(b \geqslant 0)$,
Since $\left(4 a^{2}-1,4 a^{2}\right)=1$, so $4 a^{2}-1,4 a^{2}, b$ form a primitive Pythagorean triplet,
That is, there exist $m, n \in \mathbf{N}^{\cdot}$, such that $\left\{\begin{array}{l}4 a^{2}-1=n^{2}-m^{2} \\ 4 a^{2}=2 m n \\ b=n^{2}+m^{2}\end{array}\right.$,
Considering both sides modulo 2 and 4, we know that $n$ is even, $m$ is odd, and $(m, n)=1$.
Combining $m n=2 a^{2}$, let $n=2 t^{2}$, then $(n+m)^{2}-2 n^{2}=1$
That is, $2 n^{2}=8 t^{4}=(n+m-1)(n+m+1)$,
So $2 t^{4}=\frac{n+m-1}{2} \cdot \frac{n+m+1}{2}$.
So $2 t^{4}=u(u+1)(u \in \mathbf{N})$, therefore $u, u+1$ must be $c^{4}, 2 d^{4}(c, d \in \mathbf{N})$,
So $c^{4}-2 d^{4}= \pm 1$.
(1) If $c^{4}-2 d^{4}=1$, then $d^{8}+2 d^{4}+1=d^{8}+c^{4}$,
So $\left(d^{4}+1\right)^{2}=\left(d^{2}\right)^{4}+c^{4}$ Since the indeterminate equation $x^{4}+y^{4}=z^{2}$ has no integer solutions for $x y z \neq 0$,
So $d^{4}+1, d^{2}, c^{2}$ must have one that is zero, since $d^{4}+1 \neq 0$,
So $d^{2}=0, c= \pm 1$, so $u=0$, so $t=0$, so $n=0$, so $a=0$, which contradicts $a>0$.
(2) If $c^{4}-2 d^{4}=-1$, then $d^{8}-2 d^{4}+1+c^{4}=d^{8}$,
That is, $\left(d^{4}-1\right)^{2}=\left(d^{2}\right)^{4}-c^{4}$.
Since the indeterminate equation $x^{4}-y^{4}=z^{2}$ has no integer solutions for $x y z \neq 0$, so $d^{4}-1, d^{2}, c^{2}$ must have at least one that is zero, if $d^{2}=0$, or $c^{2}=0$, then (2) does not hold, hence only $d^{4}-1=0$.
So $d= \pm 1, c= \pm 1$. Since $u$ and $u+1$ must be $c^{4}$ and $2 d^{4}$, so $u=1$, so $t=1$, so $n=2$
Since $(n+m)^{2}-2 n^{2}=1$, so $m=1$.
From (1) we know $a=1, k=2 a^{2}+1=3$, in summary, $k=1$ or $k=3$, that is, when $k=1$ or 3, $y_{3}, y_{4}$ are perfect squares, below we prove that when $k=1$ or 3, any $y_{n}$ is a perfect square:
When $k=1$, $y_{n+2}=-y_{n+1}-y_{n}+2$.
$\left\{y_{n}\right\}: 1,1,0,1,1,0, \cdots$ all terms are perfect squares.
When $k=3$, $y_{n+2}=7 y_{n+1}-y_{n}-2$.
Construct the sequence $\left\{f_{n}\right\}: f_{1}=f_{2}=1, f_{n+2}=f_{n+1}+f_{n}, n=1,2, \cdots$
Property 1 When $n$ is odd, $f_{n+2} \cdot f_{n-2}-\left(f_{n}\right)^{2}=1$.
Simple proof: Left side $=f_{n} f_{n-4}-f_{n-2}^{2}=\cdots=f_{5} f_{1}-f_{3}^{2}=1$.
Property $2 \quad f_{n+2}=3 f_{n}-f_{n-2} .\left\{f_{n}\right\}: 1,1,2,3,5,8,13,21,34,55, \cdots$
Calculation: $y_{1}=1, y_{2}=1, y_{3}=4=2^{2}, y_{4}=5^{2}, y_{5}=13^{2}, \cdots$
Guess:
$$
y_{n}=\left(f_{2 n-3}\right)^{2}(n \geqslant 3) \text {. }
$$

Below we prove by mathematical induction.
From $\left(f_{n+2}+f_{n-2}\right)^{2}=9\left(f_{n}\right)^{2}$,
So $\left(f_{n+2}\right)^{2}=9\left(f_{n}\right)^{2}-2 f_{n+2} \cdot f_{n-2}-\left(f_{n-2}\right)^{2}=7\left(f_{n}\right)^{2}-\left(f_{n-2}\right)^{2}-2$ ( $n$ is odd)
So $\left(f_{2 n+1}\right)^{2}=7\left(f_{2 n-1}\right)^{2}-\left(f_{2 n-3}\right)^{2}-2$
So $y_{n+2}=7 y_{n+1}-y_{n}-2$ can be proved by induction (3) holds, proof complete.