login
A372708
a(n) is the smallest number k that is the concatenation of the elements of a 3 X 3 matrix whose determinant is n and whose elements are a permutation of the numbers 1 through 9; a(n) = -1 if no such number k exists.
0
123456789, 123469857, 123467589, 123467895, 123458769, 123469578, 123589476, 123457689, 123748569, 123456798, 123469587, 123469875, 123458967, 123457986, 123469785, 123457698, 123548769, 123689574, 123546789, 123457896, 123569487, 123458697, 123547689, 123649758, 123567498
OFFSET
0,1
COMMENTS
The determinant of a 3 X 3 matrix whose elements are a permutation of the numbers 1..9 cannot exceed 412, so this sequence is finite.
EXAMPLE
a(0) = 123456789 because it is the smallest number that can be formed by concatenating the elements of a 3 X 3 matrix whose determinant is 0 and whose elements are a permutation of the numbers 1..9. The matrix is [1 2 3] [4 5 6] [7 8 9].
MATHEMATICA
a[n_] := a[n] = Module[{mat}, mat = Select[Partition[#, 3] & /@ Permutations[Range[1, 9]], Det[#] == n &]; If[Length[mat] > 0, First[Sort[ToExpression[StringJoin[Riffle[ToString /@ Flatten[#], ""]]] & /@ mat]], 0]];
Monitor[(* Do not use Monitor[] if using Wolfram Cloud, otherwise memory issues may occur *)Table[a[n], {n, 0, 24}], {n, Table[a[m], {m, 0, n - 1}]}] (* Robert P. P. McKone, May 11 2024 *)
PROG
(Python)
from sympy import Matrix
from itertools import permutations
adict = dict()
for p in permutations(range(1, 10)):
v = Matrix(3, 3, p).det()
if v not in adict:
adict[v] = int("".join(map(str, p)))
afull = [adict[v] if v in adict else -1 for v in range(max(adict)+1)]
print(afull) # Michael S. Branicky, May 11 2024
CROSSREFS
KEYWORD
base,fini,nonn,less
AUTHOR
Jean-Marc Rebert, May 11 2024
STATUS
approved