1. Originally Posted by undefined
The program output given above is only base 4.
So can your program also output the decimal square as well?

2. The following two images should be enough to illustrate the remaining parts of the algorithm.

So, once you have an arrangement for most significant digits, choose the top row of least significant digits, for example:

This corresponds with the beginning output of the program, above. (0's stand in for empty slots.)

This is just one of 4! possibilities for the top row; the program is written to exhaustively try all of them. But as it turns out, the very first one produces a regular square.

Now, consider that we only have two options for least significant digit for each cell.

To see why, consider the cell in the second row, first column, containing the numbers 1 (blue) 2 3 (red). We can't have 11 because that's already in the first row. And we can't have 10 because we already used 0 as least significant digit in the first row, for that column. So that leaves 12 and 13.

Now, suppose we choose 12 to go into that cell. Then notice that the cell in row 4, column 1 must become 31. Consequently the cell in row 3, column 1 must become 23. Do this throughout the entire square and see that choosing that initial 2 in row 2, column 1, uniquely determines all other cells. The result is the regular square I mentioned above.

As it turns out, there are 24 different initial arrangements of most significant digits. Each of those has 4! possible first rows. Each of those has 2 possible candidate squares.

So the program (if finished) would be finding and testing 24 * 4! * 2 candidates.

The only part I didn't explain is how a candidate can fail to be a regular square. If we follow all the steps above, we are not guaranteed to have all numbers in {0, 1, ..., 15} represented. We have to check the candidates for that property.

For the purposes of counting how many 4 by 4 regular squares exist, we would need to specify whether two squares are equivalent up to permutations of {0,1,2,3}, rotation, reflection.

3. Originally Posted by Samson
So can your program also output the decimal square as well?
Yes, the method printSquare() takes base as an argument. You can display in any base you like.

4. Regading Q1 - why any "regular square" must also be "magic":

For a base N regular square, the digits 0, 1, 2, ...N-1 must each appear exactly once in the units place for any given row/coumn. Hence the sum of the units digits is (N-1)N/2. Similarly, each digit appears once in the N's column, so it's sum is also (N-1)N/2. Hence the sum of the numbers in any row or column is:

$
\frac {(N-1)} 2 N(N+1)
$

This must be true of all columns, and of all rows. Hence the square is "magic." (However, as noted in the previous discusison about magic squares, this form of "magic square" does not require the diagonals to add to the same number as the rows and columns.)

5. Originally Posted by undefined
Yes, the method printSquare() takes base as an argument. You can display in any base you like.
Could you please post the output of the decimal version of the base 4 response you outputted? I don't have a java compiler installed locally.

6. Originally Posted by Samson
Could you please post the output of the decimal version of the base 4 response you outputted? I don't have a java compiler installed locally.
I don't see why you would want that. But here it is.

Code:
00 05 10 15
04 00 12 08
08 12 00 04
12 08 04 00

[[], [], [], [], [2, 3], [2, 3], [0, 1], [0, 1], [1, 3], [0, 2], [1, 3], [0, 2], [1, 2], [0, 3], [0, 3], [1, 2]]

00 05 11 14
04 00 12 08
08 12 00 04
12 08 04 00

[[], [], [], [], [2, 3], [2, 3], [0, 1], [0, 1], [1, 2], [0, 3], [1, 2], [0, 3], [1, 3], [0, 2], [0, 2], [1, 3]]

7. Okay! So now I have both the decimal version and the base 4 (base 4 was the first one and your last post is the decimal version of it) ?

8. Originally Posted by Samson
Okay! So now I have both the decimal version and the base 4 (base 4 was the first one and your last post is the decimal version of it) ?
You seem a bit confused.

My program did not output any regular squares. I worked it out on paper while trying the very first candidate (to use as a baseline, as a debugging aid). The first candidate worked, so I didn't bother completing the program.

So, the regular square I provided you is this

Code:
00 11 22 33
12 03 30 21
23 32 01 10
31 20 13 02

00 05 10 15
06 03 12 09
11 14 01 04
13 08 07 02
First it's given in base 4, then decimal. This should be obvious. (Otherwise, for example, the number 22 is out of range.)

Then you asked about output, so I naturally assumed you meant program output, which was near the bottom of that post.

I hope it's clear now.

9. Originally Posted by undefined
You seem a bit confused.

My program did not output any regular squares. I worked it out on paper while trying the very first candidate (to use as a baseline, as a debugging aid). The first candidate worked, so I didn't bother completing the program.
.
Okay, well now I'm confused again. Here is what I was looking for in my original post:

My book gives example for the 3 dimensional square, but does not give one for 4. Can someone help me find a 4x4 that is regular? I would like to try expressing it in BOTH regular decimal and base-n forms, and for the sake of consistency, I'd like to use a base-4 form. (I can give my example from the book upon request).
You said you didn't output any regular squares? If you did, could use just copy and paste them in a form like so:

Regular Square (Decimal) =
Regular Square (Base 4) =

Sorry for the re-hash, but i'm just a little lost here even though i'm sure what I'm looking for is already in this thread, I just cant decipher it exactly.

10. Originally Posted by Samson
Okay, well now I'm confused again. Here is what I was looking for in my original post:

You said you didn't output any regular squares? If you did, could use just copy and paste them in a form like so:

Regular Square (Decimal) =
Regular Square (Base 4) =

Sorry for the re-hash, but i'm just a little lost here even though i'm sure what I'm looking for is already in this thread, I just cant decipher it exactly.
Code:
BASE 4

00 11 22 33
12 03 30 21
23 32 01 10
31 20 13 02

DECIMAL

00 05 10 15
06 03 12 09
11 14 01 04
13 08 07 02
How much clearer can I be?????

11. And those are both regular squares? The only reason I ask about clarity is because you said your code did not output regular squares.

12. Originally Posted by Samson
And those are both regular squares? The only reason I ask about clarity is because you said your code did not output regular squares.
Maybe you don't know what base 4 means...

Code:
Base 4 Base 10
====== =======
0       0
1       1
2       2
3       3
10       4
11       5
12       6
13       7
20       8
21       9
22      10
23      11
30      12
31      13
32      14
33      15
100      16
Asking whether they are "both" regular squares makes no sense. They are the same square!

My program output is

Code:
00 11 22 33
10 00 30 20
20 30 00 10
30 20 10 00

[[], [], [], [], [2, 3], [2, 3], [0, 1], [0, 1], [1, 3], [0, 2], [1, 3], [0, 2], [1, 2], [0, 3], [0, 3], [1, 2]]

00 11 23 32
10 00 30 20
20 30 00 10
30 20 10 00

[[], [], [], [], [2, 3], [2, 3], [0, 1], [0, 1], [1, 2], [0, 3], [1, 2], [0, 3], [1, 3], [0, 2], [0, 2], [1, 3]]
There is no regular square there.

The regular square I gave you is from work I did on PAPER!

13. After doing some internet research, I've discovered that these objects have been studied by Euler, among others. See this article on Graeco-Latin squares.

Page 2 of 2 First 12