Exemple #1
0
        internal static MagicSquare[] CreateMatrices(int n)
        {
            MagicSquare[] squares = new MagicSquare[n * n];

            for (int i = 0; i < n * n; i++)
            {
                int[] initialValues = new int[n * n];
                initialValues[0] = i + 1;

                squares[i] = new MagicSquare(n, initialValues, 1);
            }

            return(squares);
        }
Exemple #2
0
        private static void Run1()
        {
            int       solutionCount = 0;
            Stopwatch stopWatch     = Stopwatch.StartNew();

            using (SolutionFile solutionFile = new SolutionFile())
            {
                MagicSquare magicSquare = new MagicSquare(4);

                magicSquare.SolutionFound += (sender, e) =>
                {
                    solutionCount++;
                    solutionFile.AddSolution(e.Solution);
                };

                magicSquare.Calculate();

                solutionFile.WriteStatistics(solutionCount, stopWatch.Elapsed);
            }
        }