Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Not A Magic Square But Similarby Limbic~Region (Chancellor) |
on Sep 06, 2013 at 17:54 UTC ( [id://1052746]=perlquestion: print w/replies, xml ) | Need Help?? |
Limbic~Region has asked for the wisdom of the Perl Monks concerning the following question:
All,
A magic square is an NxN square filled with distinct integers where all columns, rows and diagonals add up to the same value. Here is an example 3x3:
What I am trying to create has similar properties (all selections add up to the same value). A selection is defined where N numbers are chosen from the square such that each column and row may only have 1 number selected from it. Here are the possible choices for a 3x3.
This would be trivial if there wasn't a requirement for distinct values (making all values 1 for instance would suffice). Making a 2x2 is also trivial.
Ultimately, I would like squares for N=3, N=4, N=5 and possibly N=6. It doesn't matter what sum the selections add up to provided that each value is a distinct integer. Can you do it? Cheers - L~R
Back to
Seekers of Perl Wisdom
|
|