OK I just figured out the coding on my own for following Loubere's strictly. I want to get the other 3 cases down then optimize them then make one magicsquare_normal function.
def magicsquare_normal_odd(n): r""" Generates nth odd normal magic square for n greater than 1 using de la Loubere's method. EXAMPLES: sage: magicsquare_normal_odd(1) [8 1 6] [3 5 7] [4 9 2] sage: magicsquare_normal_odd(2) [17 24 1 8 15] [23 5 7 14 16] [ 4 6 13 20 22] [10 12 19 21 3] [11 18 25 2 9] AUTHOR: Timothy Clemans """ square_length = 2*n+1 square = [0 for i in range(square_length^2)] def position((row,column)): def row_id(h): return (h-1)*square_length return row_id(row)+column-1 for i in range(1,square_length^2+1): if i == 1: current_position = (1,n+1) last_position = current_position square[position(current_position)] = i elif last_position == (1,square_length): current_position = (2,square_length) last_position = current_position square[position(current_position)] = i elif last_position[0] == 1: current_position = (square_length,last_position[1]+1) last_position = current_position square[position(current_position)] = i elif last_position[1] == square_length: current_position = (last_position[0]-1,1) last_position = current_position square[position(current_position)] = i elif square[position((last_position[0]-1,last_position[1]+1))] > 0: current_position = (last_position[0]+1,last_position[1]) last_position = current_position square[position(current_position)] = i else: current_position = (last_position[0]-1,last_position[1]+1) last_position = current_position square[position(current_position)] = i return matrix(square_length,square) On 1/30/07, Timothy Clemans <[EMAIL PROTECTED]> wrote: > I think I'm going to come out with my own distribution of SAGE. One of > the features will that in the cmd line you could type "sage -version > recreation" and have an interactive puzzle machine. You could > personalize it. I would take say Martin Gardner's puzzle books and > make an interactive version. I think I would even put a mental math > thing which would take say 50^2 and give different examples of > computing it using methods from say "Math Magic". I could even create > levels of support with say the magic squares. (SAGE will X amount of > work based on which level you are on). BTW this how SAGE could become > a well-known education app. Take the rubics cube and give examples of > groups with all kinds of interaction. Not even the 3000 system that > the middle school I went to uses, does this kind of stuff. > > On 1/30/07, David Joyner <[EMAIL PROTECTED]> wrote: > > > > I think that would be really cool. > > > > Timothy Clemans wrote: > > > BTW I mean find magic squares not solve them. > > > > > > On 1/30/07, Timothy Clemans <[EMAIL PROTECTED]> wrote: > > > > > >> There is a good book on magic squares. I could start working on > > >> writing a sage app that solves magic squares. > > >> > > >> > > >> On 1/30/07, Timothy Clemans <[EMAIL PROTECTED]> wrote: > > >> > > >>> William Stein wrote it on an airplane. > > >>> > > >>> On 1/30/07, David Joyner <[EMAIL PROTECTED]> wrote: > > >>> > > >>>> Hello: > > >>>> > > >>>> It's really cool that SAGE has a sudoku solver > > >>>> http://modular.math.washington.edu/sage/doc/html/ref/module-sage.games.sudoku.html > > >>>> However, the docstring does not have any attributes. No GPL > > >>>> blurb, no author, nothing but a short description: > > >>>> > > >>>> """ > > >>>> Sudoku Solver > > >>>> > > >>>> Given a 9x9 Sudoku puzzle as an integer matrix, the program solves it. > > >>>> """ > > >>>> > > >>>> Does anyone know who wrote this? > > >>>> > > >>>> - David Joyner > > >>>> > > >>>> > > > > > > > > > > > > > > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~----------~----~----~----~------~----~------~--~---