<s>[INST] General formula for $f(n)$ 
Let for $n\geq 3, C_n$ denote the $(2n) \times (2n)$ matrix such that all entries along the diagonal are $2$, all entries along the sub- and super-diagonal are $1$, all entries along the antidiagonal are $1$, all entries along the diagonals directly above and below the antidiagonal are $2$, and all other entries are zero.
Let $f(n) : \mathbb{N}\to\mathbb{N}, f(n) = \det(C_n)$ for $n\geq 3.$ Prove that $$f(n) = \begin{cases}0,&\text{if }n = 3k+2,\ k\in\mathbb{N}\\
3^n,& \text{otherwise}\end{cases}.$$

I'm not sure how to go about doing this. I tried cofactor expansion along the first column, but I couldn't make much progress. I can't seem to find a recursive relationship. So I just tried converting $C_n$ to an upper triangular matrix using row operations. This results in a matrix satisfying certain patterns, but I can't seem to find a way to prove why reducing the matrix always produces these patterns (I can prove that the $k$th diagonal entry of the resulting upper triangular matrix is $\frac{k+1}k,$ where $1\leq k\leq n$ but I can't deal with the other $n$ diagonal entries well).
 [/INST] $\newenvironment{vsmatrix}{\left|\begin{smallmatrix}}{\end{smallmatrix}\right|}\def\mycolor#1{{\color{blue}#1}}$Denote by $D_n$ the determinant of the $2n × 2n$ matrix to be solved with $2$ replaced by $a$ and $1$ replaced by $b$. In the following calculation, rows to which Laplace's formula for determinants are applied are colored blue. If a determinant has no colored entry, it means the determinant after the next equal sign is derived by applying elementary transformations.$$
D_1 = \begin{vmatrix}a & b \\ b & a\end{vmatrix} = a^2 - b^2,\ D_2 = \begin{vmatrix}
a & b & a & b\\
b & a & b & a\\
a & b & a & b\\
b & a & b & a
\end{vmatrix} = 0,
$$\begin{align*}
D_3 &= \begin{vmatrix}
a & b &&& a & b\\
b & a & b & a & b & a\\
& b & a & b & a &\\
& a & b & a & b &\\
a & b & a & b & a & b\\
b & a &&& b & a
\end{vmatrix}
= \begin{vmatrix}
a & b &&& a & b\\
b & 0 & 0 & 0 & 0 & a\\
& b & a & b & a &\\
& a & b & a & b &\\
a & 0 & 0 & 0 & 0 & b\\
b & a &&& b & a
\end{vmatrix}
= \begin{vmatrix}
a & b &&& a & b\\
b & 0 & 0 & 0 & 0 & a\\
& \mycolor{0} & \mycolor{a} & \mycolor{b} & \mycolor{0} &\\
& \mycolor{0} & \mycolor{b} & \mycolor{a} & \mycolor{0} &\\
a & 0 & 0 & 0 & 0 & b\\
b & a &&& b & a
\end{vmatrix}\\
&= (a^2 - b^2) \begin{vmatrix}
a & b & a & b\\
b & 0 & 0 & a\\
a & 0 & 0 & b\\
b & a & b & a
\end{vmatrix}
= (a^2 - b^2) \begin{vmatrix}
0 & b & a & 0\\
\mycolor{b} & \mycolor{0} & \mycolor{0} & \mycolor{a}\\
\mycolor{a} & \mycolor{0} & \mycolor{0} & \mycolor{b}\\
0 & a & b & 0
\end{vmatrix}\\
&= -(a^2 - b^2)^2 \begin{vmatrix}b & a \\ a & b\end{vmatrix} = (a^2 - b^2)^3.
\end{align*}
For any $n \geqslant 4$,\begin{align*}
D_n &= \begin{vsmatrix}
⋱ & ⋱ &&&&& ⋰ & ⋰\\
⋱ & a & b &&& a & b & ⋰\\
& b & a & b & a & b & a &\\
&& b & a & b & a &&\\
&& a & b & a & b &&\\
& a & b & a & b & a & b &\\
⋰ & b & a &&& b & a & ⋱\\
⋰ & ⋰ &&&&& ⋱ & ⋱
\end{vsmatrix}_{2n × 2n}\mskip-18mu
= \begin{vsmatrix}
⋱ & ⋱ &&&&& ⋰ & ⋰\\
⋱ & a & b &&& a & b & ⋰\\
& b & 0 & 0 & 0 & 0 & a &\\
&& b & a & b & a &&\\
&& a & b & a & b &&\\
& a & 0 & 0 & 0 & 0 & b &\\
⋰ & b & a &&& b & a & ⋱\\
⋰ & ⋰ &&&&& ⋱ & ⋱
\end{vsmatrix}_{2n × 2n}\mskip-18mu
= \begin{vsmatrix}
⋱ & ⋱ &&&&& ⋰ & ⋰\\
⋱ & a & b &&& a & b & ⋰\\
& b & 0 & 0 & 0 & 0 & a &\\
&& \mycolor{0} & \mycolor{a} & \mycolor{b} & \mycolor{0} &&\\
&& \mycolor{0} & \mycolor{b} & \mycolor{a} & \mycolor{0} &&\\
& a & 0 & 0 & 0 & 0 & b &\\
⋰ & b & a &&& b & a & ⋱\\
⋰ & ⋰ &&&&& ⋱ & ⋱
\end{vsmatrix}_{2n × 2n}\\
&= (a^2 - b^2) \begin{vsmatrix}
⋱ & ⋱ &&&&& ⋰ & ⋰\\
⋱ & a & b &&& a & b & ⋰\\
& b & a & b & a & b & a &\\
&& b & 0 & 0 & a &&\\
&& a & 0 & 0 & b &&\\
& a & b & a & b & a & b &\\
⋰ & b & a &&& b & a & ⋱\\
⋰ & ⋰ &&&&& ⋱ & ⋱
\end{vsmatrix}_{2(n - 1) × 2(n - 1)}\mskip-54mu
= (a^2 - b^2) \begin{vsmatrix}
⋱ & ⋱ &&&&& ⋰ & ⋰\\
⋱ & a & b &&& a & b & ⋰\\
& b & 0 & b & a & 0 & a &\\
&& \mycolor{b} & \mycolor{0} & \mycolor{0} & \mycolor{a} &&\\
&& \mycolor{a} & \mycolor{0} & \mycolor{0} & \mycolor{b} &&\\
& a & 0 & a & b & 0 & b &\\
⋰ & b & a &&& b & a & ⋱\\
⋰ & ⋰ &&&&& ⋱ & ⋱
\end{vsmatrix}_{2(n - 1) × 2(n - 1)}\\
&= -(a^2 - b^2)^2 \begin{vsmatrix}
⋱ & ⋱ &&&&& ⋰ & ⋰\\
⋱ & a & b &&& a & b & ⋰\\
& b & a &&& b & a &\\
&& b & b & a & a &&\\
&& a & a & b & b &&\\
& a & b &&& a & b &\\
⋰ & b & a &&& b & a & ⋱\\
⋰ & ⋰ &&&&& ⋱ & ⋱
\end{vsmatrix}_{2(n - 2) × 2(n - 2)}\mskip-54mu
= -(a^2 - b^2)^2 \begin{vsmatrix}
⋱ & ⋱ &&&&& ⋰ & ⋰\\
⋱ & a & b &&& a & b & ⋰\\
& b & a &&& b & a &\\
&& \mycolor{0} & \mycolor{b} & \mycolor{a} & \mycolor{0} &&\\
&& \mycolor{0} & \mycolor{a} & \mycolor{b} & \mycolor{0} &&\\
& a & b &&& a & b &\\
⋰ & b & a &&& b & a & ⋱\\
⋰ & ⋰ &&&&& ⋱ & ⋱
\end{vsmatrix}_{2(n - 2) × 2(n - 2)}\\
&= (a^2 - b^2)^3 \begin{vsmatrix}
⋱ & ⋱ &&&&& ⋰ & ⋰\\
⋱ & a & b &&& a & b & ⋰\\
& b & a & b & a & b & a &\\
&& b & a & b & a &&\\
&& a & b & a & b &&\\
& a & b & a & b & a & b &\\
⋰ & b & a &&& b & a & ⋱\\
⋰ & ⋰ &&&&& ⋱ & ⋱
\end{vsmatrix}_{2(n - 3) × 2(n - 3)}\mskip-54mu
= (a^2 - b^2)^3 D_{n - 3}.
\end{align*}
Therefore,$$
D_n = \begin{cases}
(a^2 - b^2)^n; & n \not\equiv 2 \pmod{3}\\
0; & n \equiv 2 \pmod{3}
\end{cases}.
$$
</s>