Find the number of ways in which the nine digits 1,2,3,...,9 can be arranged in a 3*3 square array such that the determinant of this square is an odd integer. Each digit to be used only once.
207,360 not accounting for rotations, reflections etc.
Dividing by 4 should account for rotations.
Dividing by 4 should account for reflections.
207,360/16 = 12,960 if rotations and reflections are considered the same.
I do not think there are any matrices being counted twice as a reflection and a rotation; I do not think you can make a rotation by doing a single reflection (although I think 2 reflections can be equivalent to a rotation).
The values of these determinants take on 380 different odd integers with the smallest and largest being -407 and +407
-----------
Output:
207360
380
-407 407
-----------
from itertools import permutations
def det3(m):
x = m[0]*(m[4]*m[8] - (m[5]*m[7]))
y = m[1]*(m[3]*m[8] - (m[5]*m[6]))
z = m[2]*(m[3]*m[7] - (m[4]*m[6]))
return x - y + z
sols = []
integers = []
for perm in permutations([1,2,3,4,5,6,7,8,9]):
if det3(perm) % 2 == 1:
sols.append(list(perm))
integers.append(det3(perm))
integers = sorted(list(set(integers)))
print(len(sols))
print(len(integers))
print(integers[0], integers[-1])
|
Posted by Larry
on 2024-05-29 11:27:31 |