
MATHEMATICA

base = 3; (* base 3 is for matrix entries {1, 0, 1}, base 2 is for {1, 1} *)
decode = Which[base == 2, 0 > 1, base == 3, {0 > 1, 1 > 0, 2 > 1}];
M[n_, k_] := Module[{row0, row}, row0 = PadLeft[IntegerDigits[k , base], 2 n1] /. decode; row[i_] := RotateLeft[row0, i][[1 ;; n]]; Array[row, n]];
a[n_] := Module[{m0, d0, m, d, kmax}, {m0, d0} = {{}, Infinity}; kmax = base^(2 n  1); Print["n = ", n, " kmax = ", kmax]; Do[m = M[n, k]; d = Det[m]; If[d < d0, Print[" k = ", k, " det = ", d]; {m0, d0} = {m, d}], {k, 0, kmax}]; Print["m0 = ", m0 // MatrixForm, " a(", n, ") = ", d0]; d0];
