Package: magicsq
Magic Square ProjectThis project contains Python modules for generating magic squares, solving the N-Queens problem, and generating the Bachet matrix.ContentsBachet Matrix GeneratorMagic Square CalculatorN-Queens SolverInstallation & UsageBachet Matrix GeneratorThe Bachet matrix is a unique square matrix with a distinct construction pattern. The matrix is named after Claude Gaspar Bachet de MÃ©ziriac.Learn more.Functionsbachet_matrix(n: int): Generate the Bachet matrix of ordern.Magic Square CalculatorGenerate a 4x4 magic square matrix based on a given date or predefined values.>>> from magicsq.eulerbox import EulerMagicBox
>>> magic_square = EulerMagicBox.magicsquare("22-12-1887")
>>> magic_square
array([[22, 12, 18, 87],
       [20, 85, 20, 14],
       [84, 19, 15, 21],
       [13, 23, 86, 17]])
>>>Functionsmagicsqaure(date: str, values_list: list, random: bool): Calculate the magic square matrix based on a given data.>>> from magicsq.bachet_odd import *
>>> ordr = 5                
>>> bachet = bachet_matrix(ordr)
>>> bachet
array([[ 0,  0,  0,  0,  1,  0,  0,  0,  0],
       [ 0,  0,  0,  2,  0,  6,  0,  0,  0],
       [ 0,  0,  3,  0,  7,  0, 11,  0,  0],
       [ 0,  4,  0,  8,  0, 12,  0, 16,  0],
       [ 5,  0,  9,  0, 13,  0, 17,  0, 21],
       [ 0, 10,  0, 14,  0, 18,  0, 22,  0],
       [ 0,  0, 15,  0, 19,  0, 23,  0,  0],
       [ 0,  0,  0, 20,  0, 24,  0,  0,  0],
       [ 0,  0,  0,  0, 25,  0,  0,  0,  0]])
>>> bachet_ops = operations(bachet_ops, ordr)
>>> bachet_ops
array([[ 0,  0,  0,  0,  1,  0,  0,  0,  0],
       [ 0,  0,  0,  2,  0,  6,  0,  0,  0],
       [ 0,  0,  3, 40,  7, 48, 11,  0,  0],
       [ 0,  4, 32,  8, 50, 12,  8, 16,  0],
       [ 5,  0,  9, 42, 13, 10, 17,  0, 21],
       [ 0, 10, 44, 14,  2, 18, 20, 22,  0],
       [ 0,  0, 15,  4, 19, 12, 23,  0,  0],
       [ 0,  0,  0, 20,  0, 24,  0,  0,  0],
       [ 0,  0,  0,  0, 25,  0,  0,  0,  0]])
>>> get_center_matrix(bachet_ops)
array([[ 3, 40,  7, 48, 11],
       [32,  8, 50, 12,  8],
       [ 9, 42, 13, 10, 17],
       [44, 14,  2, 18, 20],
       [15,  4, 19, 12, 23]])N-Queens SolverSolve the classing N-Queens problem where the objective is to placeNqueens on anNxNchessboard such that no two queens threaten each other.Functionssolve(): Solve the N-Queens problem and store the solutions._queens(n: int, i: int, *args): A generator for all possible queen placements._display_chessboard(queens_positions: list): Prints a visual representation of the chessboard.>>> from magicsq.nqueens import NQueensSolver    
>>> my_queen = NQueensSolver(8)
>>> my_queen_pos_obj = my_queen._queens(8) 
>>> solution_list = list(my_queen_pos_obj)display_solutions(): Display all solutions for the N-Queens problem.>>> from magicsq.nqueens import NQueensSolver as qs
>>> my_queen = qs(8)
>>> my_queen.solve()
>>> my_queen.display_solutions(1)
+--+--+--+--+--+--+--+--+
| Q|  |  |  |  |  |  |  |
+--+--+--+--+--+--+--+--+
|  |  |  |  |  |  | Q|  |
+--+--+--+--+--+--+--+--+
|  |  |  |  | Q|  |  |  |
+--+--+--+--+--+--+--+--+
|  |  |  |  |  |  |  | Q|
+--+--+--+--+--+--+--+--+
|  | Q|  |  |  |  |  |  |
+--+--+--+--+--+--+--+--+
|  |  |  | Q|  |  |  |  |
+--+--+--+--+--+--+--+--+
|  |  |  |  |  | Q|  |  |
+--+--+--+--+--+--+--+--+
|  |  | Q|  |  |  |  |  |
+--+--+--+--+--+--+--+--+
[1, 5, 8, 6, 3, 7, 2, 4]Installation & Usagepip install magicsqLicenseThis project is licensed under the GNU General Public License v3.0 (GPLv3) - see theLICENSEfile for details.The GPLv3 is a free, copyleft license for software and other kinds of works. This means you can use, modify, and distribute this software freely as long as your derived works are also open source under the GPLv3.ContributionsContributions are welcome! Please feel free to submit a pull request or open an issue to discuss potential improvements.