NAME Math::MagicSquare - Magic Square Checker and Designer SYNOPSIS use Math::MagicSquare; $a= Math::MagicSquare -> new ([num,...,num], ..., [num,...,num]); $a->print("string"); $a->printhtml(); $a->printimage(); $a->check(); $a->rotation(); $a->reflection(); DESCRIPTION The following methods are available: new Constructor arguments are a list of references to arrays of the same length. $a = Math::MagicSquare -> new ([num,...,num], ..., [num,...,num]); check This function can return 4 value * 0: the Square is not Magic * 1: the Square is a Semimagic Square (the sum of the rows and the columns is equal) * 2: the Square is a Magic Square (the sum of the rows, the columns and the diagonals is equal) * 3: the Square ia Panmagic Square (the sum of the rows, the columns, the diagonals and the broken diagonals is equal) print Prints the Square on STDOUT. If the method has additional parameters, these are printed before the Magic Square is printed. printhtml Prints the Square on STDOUT in an HTML format (exactly a inside a TABLE) printimage Prints the Square on STDOUT in png format. rotation Rotates the Magic Square of 90 degree clockwise reflection Reflect the Magic Square REQUIRED GD perl module. EXAMPLE use Math::MagicSquare; $A = Math::MagicSquare -> new ([8,1,6], [3,5,7], [4,9,2]); $A->print("Magic Square A:\n"); $A->printhtml; $i=$A->check; if($i == 2) {print "This is a Magic Square.\n";} $A->rotation(); $A->print("Rotation:\n"); $A->reflection(); $A->print("Reflection:\n"); $A->printimage(); This is the output: Magic Square A: 8 1 6 3 5 7 4 9 2
8 | 1 | 6 |
3 | 5 | 7 |
4 | 9 | 2 |