in reply to Not A Magic Square But Similar

I'm not sure if you want some Perl number crunching or a mathematical approach...

The 3² square is actually a finite affine plane of order 3

Your "selections" are nothing else then the parallels of the diagonals¹. That means resorting the rows and columns of any magical square is also a solution for your problem.

As a proof of concept:

magical square 4 3 8 9 5 1 2 7 6

mapping rows and columns to diagonals

derived solution 4 1 7 6 3 9 5 2 8

I.a.W.: You can reuse any known algorithm for magic squares.

Nota Bene: your problem class is not equivalent but even more general (i.e. simpler) b/c the "diagonal"-requirement is missing (i.e. 2-5-8 and 4-6-5 summing up to 15 isn't needed)

HTH

Cheers Rolf

( addicted to the Perl Programming Language)

UPDATE

¹) in the case 3x3

Replies are listed 'Best First'.
Re^2: Not A Magic Square But Similar (Finite Geometry)
by kennethk (Abbot) on Sep 06, 2013 at 20:59 UTC
    For the 3² square, you are correct; we have 6 constraints, as opposed to the magic square's 8 (or really 5 as opposed to 7, given arbitrary normalization). However, for 4², we have 24 constraints as opposed to a magic square's 10; in general, constraint count grows factorially as opposed to the magic square's linear. Of course, I'm out of my depth w.r.t. geometry here, so maybe there's another mapping I'm missing.

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      Nope I was too lazy to update the cases of non-parallel "sections"¹, only mentioned it in reply to hdb (whose solution makes mine obsolete).

      But I think that hdb's solution resp. your generalization already describe the complete solution room and that all possible magic square can be found there by mapping rows to diagonals.

      So since the other way round works you will always find a back-projection from magic to "limbic" square.

      Too tired to dig into proving it, but looking into the literature for magic squares should show it's trivial.

      (unproven opinion)

      Cheers Rolf

      ( addicted to the Perl Programming Language)

      update

      ¹) and I'm still not sure if L~R really wants them.