• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Unique Square

game_federer

New Member
1. square grid with no of rows = cols = r, containing integers 1, 2, 3 …, r2 occupying the different cells,one integer per cell, so the sum of integers in each row= the sum of integers in each column = the sum of integers in each of the two diagonals.
2. for r>3

the algo is:
1. Empty all the cells.

2. Fill the middle cell of the top row= 1. Repeat step 3 till the entire square is filled:

3. The next integer in sequence is found:

A. From the cell that is just filled, go up by one row if possible; Otherwise go to the corresponding cell in the last row that is rth row.

B. Go to the column on the left if possible; otherwise, go to the corresponding cell in the last column, which is the rth column, of the grid.

C. If the cell reached at the end of the above two steps is empty, the cell is to be filled with the next integer; otherwise, the cell vertically below (i.e. one row below) the cell that is just filled is guaranteed to be empty, and is to be filled with the next integer.

Create UDF mgcSq().


Your help would be greatly appreciated.
 
Back
Top