Exemple #1
0
        static void Main(string[] args)
        {
            if (args.Contains("--yura"))
            {
                ShowIntro("SolveWithProjectionSolverRunner");

                for (var iteration = 0;; iteration++)
                {
                    if (iteration > 0 || args.Contains("-d"))
                    {
                        DownloadNewProblems();
                    }

                    Console.WriteLine("Solving...");
                    repo.GetAllNotSolvedPerfectly()
                    .OrderBy(EstimateDifficulty)
                    .AsParallel().WithDegreeOfParallelism(8)
                    .ForAll(problemSpec =>
                    {
                        Console.WriteLine($"Solving {problemSpec.id}...");
                        SolveWithProjectionSolverRunner(problemSpec);
                    });

                    Console.WriteLine("Waiting 1 minute...");
                    Thread.Sleep(TimeSpan.FromMinutes(1));
                }
            }
            else if (args.Contains("--convex"))
            {
                ShowIntro("ConvexPolygonSolver");
                var newProblems = DownloadNewProblems();
                ConvexPolygonSolver.SolveAll(newProblems);
                ConvexPolygonSolver.SolveAllNotSolvedPerfectly();
            }
            else
            {
                ShowIntro("DumbSolver");
                var newProblems = DownloadNewProblems();
                Console.Out.WriteLine($"newProblems.Count: {newProblems.Count}");
                var noSolutionProblems = repo.GetAllNotSolvedPerfectly().Where(x => repo.FindResponse(x.id) == null).Skip(15).ToList();
                Console.Out.WriteLine($"noSolutionProblems.Count: {noSolutionProblems.Count}");
                var sw = Stopwatch.StartNew();
                for (var i = 0; i < noSolutionProblems.Count; i++)
                {
                    var problem = noSolutionProblems[i];
                    Console.Write($"{sw.Elapsed:c} Problem {problem.id:0000} ({i:0000}/{noSolutionProblems.Count:0000}) ");
                    var solution = TryGetInitialSolution(problem);
                    if (solution != null)
                    {
                        ProblemsSender.Post(solution, problem.id);
                    }
                    Console.WriteLine();
                }
            }
        }