Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Magic squares

SorrowSorrow Posts: 20Member
Hi!
I'm interested in generating a sort of magic square (or rather - magic cube), when all (or some) sums are known and also some numbers to put in are known.
E.g. create a square, where sums at each column are: 15,18,22,14,19 (from left to right), and numbers in square range from 3 to 8 (each number can appear more than once).

I'd be grateful for any help.

Thanks,
Sorrow.

Comments

  • nightsurfernightsurfer Posts: 272Member
    You would really have to know a little more than that to solve it. But here's how to generate the appropriate algorithm: think of how you would do it on your own.

    In each square, assume that the value is approximately 1/4 of the sum, for a 4X4 square. Then, create the rest of the first colomn using that method. Now work across from the top row, but now each square takes 1/3 of the sum after you've subtracted what you already know. Then you work down again. When you find that you don't have enough numbers to play with, adjust 1 of the numbers set previously, and try again, until you reach the bottom right corner. If you did it right, then the sum of the diagonals should equal the number printed in the bottom corner.


    Your most important program will require more memory and processing power than you have.

Sign In or Register to comment.