473,548 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

magic square topograhical model

4 New Member
I need help ... I have very rudimentary VB skills. I am working on a topographical model of a magic square. I consider each cell in the square to be a solid structure to the height specified by the value in the square. Then conceptually I pour water on the structure and wish to see where the water collects in "lakes" on the structure.

What I think I need is a program that will generate all unique paths from a cell in the interior of the square to the exterior of the cell. I can readily search those paths for the one with the least high obstruction on the way out.

I would like a program that for and order of square will generate the unique paths out ?

Very appreciative for any help on my project

Thanks
Aug 10 '07 #1
5 2205
Killer42
8,435 Recognized Expert Expert
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.
Aug 10 '07 #2
magic man
4 New Member
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
Aug 10 '07 #3
Killer42
8,435 Recognized Expert Expert
I won't have time to look into this for a while. In the meantime, you might want to have a look at the entry on Wikipedia, and I really do think you should put an entry in the Cafe/Lounge, or Software Development forum. This sort of question should have wider exposure than just the VB forum.

I can move the thread over there, if you like, so you don't have to do it all again.
Aug 11 '07 #4
magic man
4 New Member
Thanks for your kind help. I took your suggestion and posted the problem on the link you gave me. I feel certain that someone has solved this problem in the past .. and there is no sense in me reinventing the wheel ....

I have been caught up in the muse of the symmetry of the magic square structure. I have yet to find someone who has developed a practical use for it ... thus the model building effort. Harvey Heinz has a great web site on magic squares.

I have a model assigning weights to the cells ... that a physics professor - Peter Loly has written several papers on the moment of inertia and the harmonics/eigen values of such structures...

The topographical model ... I think will be of interest ...

and am trying to invent a time model for the magic square structure
Aug 11 '07 #5
Killer42
8,435 Recognized Expert Expert
... I have been caught up in the muse of the symmetry of the magic square structure. I have yet to find someone who has developed a practical use for it ... thus the model building effort. Harvey Heinz has a great web site on magic squares.
I thought the Wikipedia article mentioned a few purposes they have been used for. I didn't read it in detail, though - just skimmed briefly.
Aug 12 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
4725
by: winnerpl | last post by:
Hey guys I'm trying to get a magic square but I'm stuck with it printing out only 1's and 0's in random places. Hope you experts can can provide some input on what I'm doing wrong. #include <stdio.h> #define MAX 20 int x; int size_request(void); //asks the user to enter the size x size square.
1
10526
by: shaveta | last post by:
pls guide me to write a program in c to generate a magic square of size n*n , where n is odd A magic square is an n*n matrix of integer from 1 to n^2, where n is odd, such that the sum of every row, column and diagonal is same. The rule is - Start with 1 in the middle of the first row; then go up and left , assigning nos. in increasing...
4
1815
by: jyck91 | last post by:
can any one tell me?? what should i do before i strating wirtitng the magic square programe
8
3707
KoreyAusTex
by: KoreyAusTex | last post by:
I am pretty new at programming and need some feedback as to why this program is not working??? It was a pretty big undertaking for me but I can't seem to figure out what is wrong: import java.util.*; public class MagicSquare { public static void isMagic (int b) { int sum = 0;
2
2564
by: jyck91 | last post by:
i have done the magic square: #include <stdio.h> #include <stdlib.h> #include <string.h> #define SIZE 13 main() { FILE *fp; int i, j, n, row, column;
1
3902
by: magic man | last post by:
I am 50 years old ...and am working physical models of the math structure called a magic square .. for my own interest. My present problem is this. I have a topograhical model for the square ... where each cell in the square is a solid structure to the height specified by the value in that cell. Then conceptually I pour water on top of the...
1
4163
by: manju01 | last post by:
in the below program we can generate magic square of size 3-160 but i want to print the output like for magic size n ************************ * * * * * * 5 * 8 * 7 * 6 * ************************ that is in grid
4
3403
by: inferi9 | last post by:
Hi, I am working in a program caals magic square and it must be done only with loops and user definied funcations,I will tell you about my code and where my problem, the main is only calls the other funcations,The first funcation makes a squence which the user input where it begins and the differents between easch elements the size of this one...
1
3409
by: sanaanand2008 | last post by:
can u pls help me out write the prgm to check whether the entered matrix is a magic square or not?
0
7444
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7711
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7954
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7467
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7805
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6039
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5085
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3497
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3478
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.