A263542
Triangle T(M, N): Number of M X N matrices where 1
24, 112, 376, 768, 2160, 20352, 5376, 5904, 86208, 51840, 64512, 56736, 1628352, 1342656, 44084736
Offset: 2
Examples
One 3 X 3 solution (with a sum of 19) is: 0 4 2 8 7 6 3 1 5 One 4 X 4 solution (with a sum of 30) is: 0 3 4 7 12 15 8 11 1 2 5 6 13 14 9 10 One 5 X 5 solution (with a sum of 48) is: 0 24 1 23 2 9 15 8 16 7 10 14 11 13 12 19 5 18 6 17 20 4 21 3 22 The triangle T(M, N) begins: M\N 2 3 4 5 6 ... 2: 24 3: 112 376 4: 768 2160 20352 5: 5376 5904 86208 51840 6: 64512 56736 1628352 1342656 44084736 ...reformatted. - _Wolfdieter Lang_, Dec 16 2015
Links
- The Nineteenth Byte, Originating chat message, ChatRoom.
Programs
-
Python
from itertools import permutations as P n = 4; m = 4; permutes = P(range(m*n), m+n); counter = 0 for p in permutes: grid = [p[:n]] for i in range(m-1): grid.append([p[n+i]]+[-1]*(n-1)) grid[1][1] = p[-1] s = p[0]+p[1]+p[n]+p[-1] has = list(p) fail = 0 for y in range(1,m): for x in range(1,n): if x == y == 1: continue r = s - (grid[y-1][x-1] + grid[y-1][x] + grid[y][x-1]) if r not in has and 0 <= r < m*n: grid[y][x]=r has.append(r) else: fail = 1 break if fail: break if not fail: counter += 1 print(counter)
Comments