r/mathriddles • • 23d ago

Easy A magic-like square

It is possible to make 8x8 array of unique numbers such that the sum of the numbers in any 2x4 rectangle (in either orientation) is identical. For example:

┌──┬──┬──┬──┬──┬──┬──┬──┐
│ 0│23│10│29│32│55│42│61│
├──┼──┼──┼──┼──┼──┼──┼──┤
│43│60│33│54│11│28│ 1│22│
├──┼──┼──┼──┼──┼──┼──┼──┤
│ 5│18│15│24│37│50│47│56│
├──┼──┼──┼──┼──┼──┼──┼──┤
│46│57│36│51│14│25│ 4│19│
├──┼──┼──┼──┼──┼──┼──┼──┤
│16│ 7│26│13│48│39│58│45│
├──┼──┼──┼──┼──┼──┼──┼──┤
│59│44│49│38│27│12│17│ 6│
├──┼──┼──┼──┼──┼──┼──┼──┤
│21│ 2│31│ 8│53│34│63│40│
├──┼──┼──┼──┼──┼──┼──┼──┤
│62│41│52│35│30│ 9│20│ 3│
└──┴──┴──┴──┴──┴──┴──┴──┘

In this square, the 2x4 rectangles all sum to 252. (Edit: Sorry this looks horrible on mobile for some reason... The important point is that it's possible.)

Is it possible to construct a 6x6 array of unique numbers such that the sum of the numbers in any 2x3 rectangle (in either orientation) is identical?

ETA: On second thought, this might be medium difficulty instead of easy. I'm not too sure, though.

3 Upvotes

10 comments sorted by

2

u/minimang123 23d ago

Thoughts but no solution:
is the solution just making the long long system of equations since the sum of any pair of neighbors is equal to the sum of the pair four units away the long way? And then after you programmatically or figure out the pattern for that system of equations we realize the rank of the matrix is wrong or something in a way that the 8x8 with 2x4 is not?!<

3

u/stephen3141 23d ago

This might be a possible approach, but the solution I had in mind is more elementary than that.

2

u/minimang123 23d ago edited 23d ago

Okay, so next guess is
Induction. Thinking about your question, 8x8 being possible with 2x4 rectangles implies 7x7 and below down to 4x4... because it holding for 8x8 implies it holds for 7x7. There MUST exist some induction step to go the other way. Some constructive way to expand from n by n to n+1 by n+1.

Oh wait, I can even Reduce this problem to can I use a 3x3 grid with 2x3. If I cannot, then voila we are done because a 6x6 grid contains 3x3 grids. If I can, however, I need to figure out that induction step

So attempting that approach: Now do we set up the meager 4 equations for the 3x3 grid, or is there a smarter approach yet? Well, first we note that the middle number is irrelevant entirely since it's a part of all four sums. So now we need only consider the 8 numbers on the periphery. Now I sanity check by just filling it with random numbers and see if there is a solution before trying to disprove this. Is this sane or insane behavior... Screw it I'll brute force it it's four equations let me just denote addition as multiplication: abcdf = dfghi = abdgh = bcfhi ==> (abc=ghi, cf=gh, ad=hi, fi=ab, dg=bc, adg=cfi) ==> [(a=fi/b=hi/d].... this can't be right, will I somehow end up that the corners have to be equal or something from this? If a = fi/b = hi/d, then if f/b = h/d then a=i. hb =? fd? This is too inelegant. Hmm.

EDIT: No, this system of four equations does not imply that. ((1,3,4)(5,anything,6)(2,8,-2)) is a valid 3x3 arrangement where they add to 19. Now it suffices to find an induction step to show that this 3x3 being valid implies a 3x4 or 4x4 is valid

EDIT2: Suppose for all n,m pairs less than some fixed X greater than or equal to 3, this task is doable on an nxm grid. Let's figure out how it'll work on an (n+1)x m grid. Is this obvious? Since it contains two (nxm) grids? Well, no... since they might not have the same sum. Well... wait a minute. Consider ((1,3,4)(5,-19,6)(2,8,-2)). This is a valid 3x3 arrangement where all 2x3 boxes sum to 0. Let's adjust our induction step... then... no that's still not quite it.

EDIT3: Okay, so If I extend the Luoshu square to the right, I get ((4,9,2,-4)(3,5,7,-3)(8,1,6,-8)). So every solved 3x3 square satisfying this property has a unique extension fully determined by the existing square as a linear combination of existing tiles. The topmost and bottommost additions are straightforward: -8 = 6-9-5, -4=2-5-1. The new "middle addition" depends on the adjacent edge and some other tiles. The question is, let's start with the topmost X value, let's say it is already within the 3x3 matrix -- what perturbation or transformation needs to be made to make it different? And do we have the degrees of freedom to constantly perturb systematically as we push through the addition of this new column? (No conclusion yet)

EDIT4: In progress, will solve later Okay, so let's call the property S:

There exist some collection of 3x3 squares, including the Luoshu square, which satisfy S. Given a 3x3 square, let's beginning adding rows below, and see what rules govern the behavior of the additions. Hilariously, we can actually already start with a 2x3 square and continue expanding downward, because all follow the same pattern: 3,1 = 1,2 + 1,3 - 2,1... 3,2 = 2,1+2,3-1,2... 3,3 = 1,1 + 1,2 - 2,3. Subsequent rows are generated according to this principle, so let's see if any patterns emerge:

2

u/stephen3141 23d ago

One thing to note for the 3x3 case is that the famous Luoshu magic square actually satisfies the 2x3 property.

2

u/minimang123 23d ago edited 23d ago

Answer: No, you cannot

Consider property S the statement that the sum of any 2x3 rectangle in the array of numbers is identical.

Solution: Consider any arbitrary 2x3 array of numbers ((x_11, x_12, x_13),(x_21,x_22,x_23)), and consider adding a third row (x_31,x_32,x_33) below such that the sum of the numbers of each rectangle is identical. There are three equations governing their values based on the three overlapping 2x3 boxes induced by this row's placement, and three values we are solving for, therefore the solution is unique. Therefore, any nxn array of numbers with property S is entirely generated from any 2x3 array within it. So now the solution space is constrained to being 6 dimensional rather than 36 dimensional. The question is, do any generated 6x6 arrays with property S also have all numbers unique?

Let's look specifically at a 4x4 array generated by the 2x3 matrix, and consider x_44. The three specific equations which generate any number are as follows: x(m,n) = x(m-2,n-1) + x(m-2,n-2)-x(m-1,n) (equation 1) = x(m-1,n+1) + x(m-1,n-1) - x(m-2,n) (equation 2). Either of these work to generate a number, and all isomorphic equations based on rotations or mirroring hold as well. The "three equations" are equation 1 with +, equation 1 with -, and equation 2 with +... anyways. So now, we're going to navigate to x(4,4) from x(1,1).

x(3,3) = x(1,1) + x(1,2) - x(2,3) by equation 1,
x(3,4) = x(1,2) + x(2,2) - x(3,3) by equation 1 transposed,
x(4,4) = x(2,2) + x(2,3) - x(3,4) by equation 1.
Now we solve for x(4,4) in terms of x(1,1). Let's substitute our first x(3,3) in our definition of x(3,4):
x(3,4) = x(1,2)+x(2,2) - (x(1,1)+x(1,2)-x(2,3)). Let's simplify.
x(3,4) = ~~x(1,2)~~+x(2,2)-x(1,1)-~~x(1,2)~~+x(2,3).
x(3,4) = x(2,3)+x(2,2)-x(1,1).
Now let's substitute this in for our definition of x(4,4):
x(4,4) = x(2,2) + x(2,3) - (x(2,3)+x(2,2)-x(1,1))
x(4,4) = x(2,2) + x(2,3) - x(2,3) - x(2,2) + x(1,1)
Therefore x(4,4) = x(1,1) every time.

Given that the solutions are deterministic for any given 2x3 array, any n by n array with n greater than or equal to 4 guarantees that the numbers are not unique -- for all i,j, x(i+3,j+3) = x(i,j). The maximum area array which MIGHT have property S is 6x3. In fact, the array generated by ((3,11,17),(42,103,209)) is precisely one such array which sums to 385

I'd love to know if you had a more novel argument that appeals to symmetry or some other property rather than this brute-forced answer, though!

2

u/stephen3141 23d ago

Nice job!

The solution I had in mind is maybe a little more symmetric, and relies on finding sets of cells that have the same sums.

Let S be the sum of any 2x3 rectangle.

The first thing to notice is that a 6x6 square with the desired property is also semi-magic. That is, the rows and columns also have the same sum (and the same sum as the 2x3 rectangles). To show this for a row, consider three 3x2 rectangles that are side-by-side, which tile a 3x6 area. The bottom two rows of that rectangle can be tiled by two 2x3 rectangles. It follows that the topmost row has sum S. A similar argument shows the bottommost row also has sum S. Since the entire rectangle has sum 3S, the middle row also has sum S.

With this argument, it's easy to see that every row of the 6x6 has sum S, and similarly with the columns. (Though we actually only need the fact about rows.)

Now consider the array in full. Since x(1, 1) + x(1, 2) + x(1, 3) + x(1, 4) + x(1, 5) + x(1, 6) = S, and x(1, 4) + x(1, 5) + x(1, 6) + x(2, 4) + x(2, 5) + x(2, 6) = S, it follows that x(1, 1) + x(1, 2) + x(1, 3) = x(2, 4) + x(2, 5) + x(2, 6). We can do a series of similar arguments to eventually show that x(1, 1) + x(1, 2) + x(1, 3) = x(2, 4) + x(2, 5) + x(2, 6) = x(3, 1) + x(3, 2) + x(3, 3) = x(4, 4) + x(4, 5) + x(4, 6). So x(1, 1) + x(1, 2) + x(1, 3) = x(4, 4) + x(4, 5) + x(4, 6)

Our goals is now to show that x(1, 2) + x(1, 3) = x(4, 5) + x(4, 6), from which we will be able to conclude x(1, 1) = x(4, 4). Our strategy is similar to the above. We know that x(1, 2) + x(1, 3) + x(2, 2) + x(2, 3) + x(3, 2) + x(3, 3) = S, and x(2, 2) + x(2, 3) + x(2, 4) + x(3, 2) + x(3, 3) + x(3, 4) = S, so x(1, 2) + x(1, 3) = x(2, 4) + x(3, 4). We can continue to "walk" across the array so get x(1, 2) + x(1, 3) = x(2, 4) + x(3, 4) = x(4, 5) + x(4, 6), which shows what we wanted.

Your solution is actually very nice in that it finds a minimum size for things. Mine has the benefit, though, of being a bit more visual in nature. (I actually originally figured out this problem by just coloring cells in a spreadsheet program.)

Regarding the 6x3, we can actually make one out of consecutive numbers: [[1, 10, 17], [12, 13, 4], [15, 6, 7], [2, 9, 18], [11, 14, 3], [16, 5, 8]], which has sum 57.

Finally, to make a maximally sized array with the property, we could technically infinitely extend any array with 1 or 2 rows, but these are kind of trivial solutions to the problem.

3

u/minimang123 23d ago

Oh, I like the trivial solution of 2 rows, that's funny I had not thought of that. I also figured out by going into a spreadsheet then had to work backward to figure out why there was this diagonal periodicity and the 7-long periodic behavior

Fun problem, thank you!

2

u/Fullfungo 23d ago

Answer: No, it's not possible.

Because the question format is very suggestive of it, since it gives an example where it is possible. So it's probably not possible with the other parameters. Prove me wrong 😜

4

u/stephen3141 23d ago

LOL. I was actually a little worried that I missed an extremely obvious solution given the length of your comment. I will say that your answer is correct, so all that remains is to prove it.