Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: magic squares

by ELISHEVA (Prior)
on Apr 05, 2009 at 08:15 UTC ( [id://755540]=note: print w/replies, xml ) Need Help??


in reply to magic squares

And the solution is .... (withdrawn - too many bugs and faulty logic. But I've keep the code in case anyone wants to play with it.).

Update: withdrew solution due to bugs

Replies are listed 'Best First'.
Re^2: magic squares
by ELISHEVA (Prior) on Apr 05, 2009 at 17:52 UTC

    Henry Higgins: By George, she's got it, By George, she's got it. (or so I hope). I finally managed to debug the script and changed the solution strategy... and who do you think doesn't have a magic square to show the teacher?

    On my system the script took 0.69s between 0.40 and 0.48s to print the above output.

    The code follows:

    Update: moved end of spoiler section.

    Update: made two small changes to increase speed by 30-40%

      There is still a bug in your logic. There are over 70 magic squares with all of the letters J O H N and you didn't find most of them.

      Update: I misread the format that ELISHEVA printed her results in. My bad.

        On purpose, but I reread the explanatory portion of my post and I can see how one might have thought otherwise. The algorithm isn't intended to find all of them. Finding one is all that is needed for the stated problem: which student doesn't have a magic square with their name written on it.

        Best, beth

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://755540]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-19 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found