Magic Squares

Note:The 6x6 magic square is only semi-magic because of an earlier error in my code. The code had been corrected, but I have not changed the illustration. Thanks Amir.


THE MAGIC SQUARES PROJECT


Introduction

We have been encouraged to complete a computer project using VB.NET to produce an application that will create magic squares of any size from three up to a practical limit, including the odd numbered squares (2n+1: 1,3,5,7,..), the doubly-even squares (4n: 4,8,12,16,...) and the singly-even squares (4n+2: 6,10,14,...). The purpose of this page is to propose a mechanism by which we can work together (TEAM WORK) and produce a super-application. At the end of this page, there are some resources that may be of help.

The components of the application

The application consists of:
  • The user interface: Forms, buttons, labels, textboxes to interact with the user of the application. These have to be designed to be user friendly, easily understandable, and optionally provide background information on the subject matter including help.
  • The events routines: these are the driving force of the application, enabling fool-proof error-trapping, putting focus where input is expected, providing scroll bars where required, data verification, error-messages, etc.
  • The magic square routines: I believe it is in the best interest of a programming class to have AS MANY ROUTINES as there are offers. We just have to give the user a choice the routine to use, which enhances the variety of the application, and certainly add to the value of the contributions of everyone.
  • Documentation: It is not easy, few programmers enjoy writing up the application documentations, otherwise they became technical writers or translators! It is a necessary part of the project, and in fact, within the limited experience I had, I find that it is much easier to write the documentation BEFORE you write the programme. The advantage is very simple: it makes us THINK and PLAN the application before we even start, and we have a book to follow as we go along. The best part is there is no drag (of writing up the documentation) at the end when you think the job is finished!

    How work may be distributed and coordinated

    As some of us work, some of us go to school, it may be difficult for us to meet more than once a week, that is, during class. If it is possible at all, try to arrive class by 09:30 on Saturdays so we have a little time to exchange information and our views.

    During the week, I propose to use this web site to distribute information, which you'd be able to read, to cut-and-paste, and to download files and the latest code. If you have written up code, I will try to integrate it into the current version of the application and do some preliminary testing. I will write a report, comments, and so on so that the author or other members could have some feedback. I will also upload the latest version of the application every time it is revised. So you'd always have access to the latest version. Also, I will publish the comments and feedback that I receive, so that we can all be aware of the evolution of the application.

    For those who are interested on the algorithmic part of the programming, you could write as many routines as you want, and they will all be included in the programme, with individual access. For example, we could have a choice of routine after the size of the magic square has been chosen, according to availability

    We only have three algorithms implemented (Siam,Diamond,LUX). We need more varieties. Please chip in!

    Don't miss the live discussions on Saturday mornings (09:30-10:00)


    Programming resources
    Feel free to download this application for reference, for testing, or just for fun. They have been tested till 50x50
  • MagicSquares VB project files, updated 2003-11-21 14:33
    2003-11-22 17:30 Corrected omission of btnGlossary_Click
    2003-11-21 14:33 Add mag.sq. properties,corr.LUX method.,added glossary
    2003-11-16 21:28 added Odd magic squares (2N-1)
    2003-11-16 20:55 added doubly-even magic squares (4N)
    2003-11-14 23:31 Trivial case implemented (N=1)
    2003-11-14 23:15 Lux algorithm for 4m+2 magic squares implemented
    2003-11-14 19:42 Complete application, waiting for different algorithms to be implemented.
    Lux algorithm to be completed.



  • References
  • Magic Square Internet resources


  • Some highly recommended links:
    A Great site from Germany (Shows many, many examples of DIFFERENT methods. Some pages are in German only, but are quite understandable)
    Mathworld site (contains algorithms for all three types of magic squares)

    Last updated:
    2003-11-21 14:33 new version of MagicSquares
    2003-11-19 18:57 added link to German site
    2003-11-16 21:42
    2003-11-14 23:31