It sounds as though you should go to the Software Development forum to get some info on how to go about this. Once you've got the method, I believe we will be able to convert it to VB quite simply.
I feel a little embarrased asking someone else to do my work ... but I just don't seem to have the mental horsepower to get it done ...
I emailed a lot of Einstein type people in the math field and got two replies on how I should approach this ...
Just for general interest ... there are 880 different 4x4 magic squares.
There are 3600 different 5x5 magic squares .. of a special variety .. they call pandiagonal magic squares. Harvey Heinz has them enumerated on his web site on magic squares .. so I can search through those examples for my data ..
... but I digress ...
*************** *************** *
A real nice guy called paul black @nist.gov ... ? some government guy for algorithm standards emailed me back and said I had to do the following..
#1. "you should use a depth-first algorithm with flags to avoid loops "
( I have no acquaintance with that)
#2. "for each cell in the interior find every path from c to the exterior...
he refers to this fct as FAREPFHTTE
FAREPFHTTE (C)
for each direction up (+1 0), down (-1 0), left (0 +1), and right (0 -1)
nextc = c+ direction
if nextc is already in the path, skip it
if nextc is exterior, report path
otherwise call FAREPFHTTE(next c)
*** paths cannot take diagonals ***
we don't want the program to try up, down, up, down over and over so how can we mark that the cell is already in the path? Well keep an array of cells and mark each one as we take it ( and unmark each one as we leave it) so now it is
FAREPFHTTE(C)
A(c) = 1 # mark that c is in use
for each direction up (+1 0 ), down (-1 0), left (0 +1) and right (0 -1)
nextc = c + direction
if A(nextc) is 1 , try next direction # it is already in the path, skip it
if nextc is exterior, Print P #print what we have
otherwise call FAREPFHTTE (nextc,P."nextc ")
A(c) = 0 # mark that c is no longer used
*************** *************** ****
I have tried to just write by hand ... all the unique paths from one coner inner cell for the 5x5 square and got 91 unique different paths ....
I have never written a recurssive program ... just for next loops and I know how to insert a simple sort program ... so I can easily sort the paths once I have them. I can also write the code to rotate the square ... so once I have the soln for a given interior square .. I can rotate the orginal square ... and thus for 5x5 square ...only have to define 3 differnt cells in that square ...
********
Lastly I enclose a picture of a order 5 magic square that I made a "mass" model for
Thanks alot
well I guess I don't know how to insert a picture in this email
Craig