private BigInteger PrivateSolve(TypeOfAlgo type, BigInteger a, BigInteger b, BigInteger p)
        {
            BigInteger result = -1;

            switch (type)
            {
            case TypeOfAlgo.BruteForce:
                result = BruteForceMethod.Solve(a, b, p);
                break;

            case TypeOfAlgo.SimpleFormula:
                result = SimpleFormula.Solve(a, b, p);
                break;

            case TypeOfAlgo.Matching:
                result = MatchingAlgorithm.Solve(a, b, p);
                break;

            case TypeOfAlgo.PohligHellman:
                result = PohligHellmanAlgorithm.Solve(a, b, p);
                break;

            case TypeOfAlgo.PollardRho:
                //result = PollardRhoAlgorithm_Modification.Solve(a, b, p);
                result = PollardRhoAlgorithm.Solve(a, b, p);
                break;
            }

            Console.WriteLine(CheckResult(a, b, p, result) ? "____________________correct" : "wrong");

            return(result);
        }
        private List <Tuple <TypeOfAlgo, double> > PrivateAnalyze(List <TypeOfAlgo> types, int a_digits, int b_digits, int p_digits, int numRuns)
        {
            List <Tuple <TypeOfAlgo, double> > result = new List <Tuple <TypeOfAlgo, double> >();

            for (int iType = 0; iType < types.Count; iType++)
            {
                GenerateNumbers(p_digits, a_digits, b_digits,
                                out BigInteger p, out BigInteger a, out BigInteger b);

                TypeOfAlgo type           = types[iType];
                double     allTimeForRuns = 0;
                bool       first          = true; //bad result
                for (int iRun = 0; iRun < numRuns; iRun++)
                {
                    var        watch  = System.Diagnostics.Stopwatch.StartNew();
                    BigInteger solved = Solver.Solve(type, a, b, p);
                    watch.Stop();
                    if (Solver.CheckResult(a, b, p, solved))
                    {
                        allTimeForRuns += first ? 0 : watch.Elapsed.TotalMilliseconds;
                        first           = false;
                    }
                    else
                    {
                        iRun--;
                    }
                }
                double averageTime = allTimeForRuns / (numRuns - 1);
                result.Add(new Tuple <TypeOfAlgo, double>(type, averageTime)); //+
                Console.WriteLine($"{type}: {averageTime}");
            }
            return(result);
        }
        private void StartProcess(TypeOfAlgo type, Label label)
        {
            ParseVariables();

            //TODO measurer
            var        watch  = System.Diagnostics.Stopwatch.StartNew();
            BigInteger result = Solver.Solve(type, A, B, P);

            watch.Stop();
            double elapsedMs = watch.Elapsed.TotalMilliseconds;

            //TODO red background if -1
            //TODO "Time: error"
            textBoxX.Text = result.ToString();
            label.Text    = "Time: " + elapsedMs.ToString() + " ms";
        }
 public static BigInteger Solve(TypeOfAlgo _type, BigInteger _a, BigInteger _b, BigInteger _p)
 {
     return(Instance.PrivateSolve(_type, _a, _b, _p));
 }