# grid combinatorics problem

We have a grid of 3 rows on 13 columns.

On the first row, we have integers from 1 to 13 in ascending order.

On the second row, we have these same integers in any order.

On the third row, we write the absolute value of the difference of the two integers of each column.

Let N be the number of ways to fill the 2nd row so that 13 distinct integers are on the 3rd row.

Let N (k) be the number of solutions for which the integer k of the 1st and 2nd row appear in the same column.

Thus, N is equal to the sum of N (k) for k ranging from 1 to 13.

What is the sum of k x N (k) for k ranging from 1 to 13?

For instance, here's a solution with k=8 :

Row 1   1  2  3  4  5  6  7  8  9 10 11 12 13

Row 2   5 13 12 11 10  7  9  8  6  4  3  2  1

Row 3   4 11  9  7  5  1  2  0  3  6  8 10 12


Note how 8 is in the same position in rows 1 and 2, giving a 0 in row 3. The quantity of such solutions is N(8), and I would add 8 * N(8) as that term in the requested summation.

I don't know the result of the problem; can you help me?

• Did you try to see what happens for a smaller board, e.g. with 3 rows and only 4 or 5 columns? Maybe you'll start to see a pattern then. – Bram28 Nov 13 '17 at 20:16
• This is possible for a permutation of length 12 or 13, but impossible, for example, for a permutation of length 10 or 11, and in general, for a permutation of length $2$ or $3$ $\mod 4$. This is because the sum of the entries in the Row 3 must be even, and for permutations of length $2$ or $3$ $\mod 4$ that sum is odd. – Alexander Burstein Nov 14 '17 at 7:35
• Are you still interested in this problem? Why do you think sum $kN(k)$ will be interesting? Why did you pick 13? – Stephen Meskin Dec 13 '17 at 6:03